injectJavascript static method
Implementation
static String injectJavascript({String source = 'native'}) => '''
const dispatchEvent_original = EventTarget.prototype.dispatchEvent;
function dispatchEvent(event) {
if (event.type) {
${source == 'web' ? 'window.parent' : 'PE'}.postMessage(JSON.stringify({
type: 'PayEngine',
event: {
type: event.type,
detail: event.detail
}
}))
}
}
EventTarget.prototype.dispatchEvent = dispatchEvent;
''';