I been trying to understand what part of code on youtube.com does redirect you to another site when clicking on a link in the description. For that I have tried to prevent all events to run in relation to the clicked element, but that does not help:
Object.keys(window).filter(
k => /(?=^on)(?!.*move)(?!.*pointerup)(?!.*auxclick)/.test(k)
).forEach(key => {
et.addEventListener(key.slice(2), ex => {
console.log(`stop: ${key}`)
ex.stopPropagation()
ex.preventDefault()
})
})
So I went to the browser console and checked which function is called when the button is pressed. However, when I try to call this function from the debugger, I get `x is not defined'.
Can someone explain why these functions are not accessible, and it's not possible to overwrite them, even from an extension code using a content script?
So, you can hijack the
addEventListenerfunction itself, you can find its source fromwindow.__proto__.__proto__.__proto__which containsaddEventListener,removeEventListeneranddispatchEventPaste the following code in a youtube tab's inspect element console; no event listeners would be added, neither would any of the globals you referenced be useful and the tab that this code would open, while technically youtube would be VERY BROKEN
EDIT:
addEventListeneris modified to do default behaviour for everything exceptclickevents