'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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
