https://pastebin.com/Ye7Kn2Vt
Anyone know what is the issue?
I think this is because each iframe has its own document and you need to add eventListeners to the iframes contentDocument?
See
https://stackoverflow.com/questions/68063629/window-addeventlistener-stops-working-once-iframe-is-loaded-inside-body
https://jsfiddle.net/7h0jfv3x/
@purplepinapples
The problem is that the iframe is from a different website and domain, so that is probably why the code below doesn't work
document.querySelector("#frame").contentWindow.addEventListener('keydown', function (e) {
console.log(e.target)
console.log('hi')
})
No matter what I do when I click on the iframe and it get's focused I can't make any event listeners work and be trigged.
The script does detect the event listener n and l keypresses as long as I haven't clicked on the iframe and it is not focused.
Does anyone know how to fix this?
This script has to be used https://greasyfork.org/en/scripts/411391 so that you can test my script on this page for example https://www.crunchyroll.com/date-a-live/episode-11-past-sins-842798
This is my code so far https://greasyfork.org/en/scripts/448382-testy/code
*Check lines 66-80