Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

180
Views
node JS/ python injection script simulating enter key press

I have two issues :

One when injecting my javascript into the iframe, it is saying 'Unexpected Token : ';' ' Yet if I input the same script manually via Devtools, it runs just fine.

I am using a cruncher function:

def cruncher( manylines ):
#lines = manylines.replace('"', '\\"')
lines = manylines.replace('"', "'")
return ';'.join( lines.splitlines() )

INDEX = INDEX.replace('$INJECTION$', cruncher(TEST1))

to inject the script, and it works for all other parts my script except for TEST1 (defined below)

function partb() {
console.log('running partb')
var PO_ID = document.getElementById('freeTextFilterId')
var enter = new KeyboardEvent('keyup', {altKey:false,
bubbles: true,
cancelBubble: false,
cancelable: true,
charCode: 0,
code: 'Enter',
composed: true,
ctrlKey: false,
currentTarget: null,
defaultPrevented: true,
detail: 0,
eventPhase: 0,
isComposing: false,
isTrusted: true,
key: 'Enter',
keyCode: 13,
location: 0,
metaKey: false,
repeat: false,
returnValue: false,
shiftKey: false,
type: 'keyup',
which: 13})
PO_ID.dispatchEvent( enter )
}

setTimeout( partb, 1000 + Math.random() );

Again if I input TEST1 script manually, directly into the devTools, the script runs fine, and I am able to programmatically click the enter key in the textbox I desire. But If I run the script and inject TEST1 using my cruncher function, I get: Uncaught SyntaxError: Unexpected token ';'

Please help

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!