Answer the question
In order to leave comments, you need to log in
Is it possible to track the change in the Eventlistener of an element? Or protect the EventListener from changes?
There is Firefox extension code that runs on the page as soon as it is created:
document.addEventListener("keydown", (e)=>console.log(e), false);
Answer the question
In order to leave comments, you need to log in
In general, as I understand it, the listener was deleted like this :
var oldRoot = document.documentElement;
var newRoot = oldRoot.cloneNode(true);
oldRoot.parentNode.replaceChild(newRoot, oldRoot);
var oldEventListenerKeeper = document.documentElement;
var observer = new MutationObserver(function(mutations)
{
mutations.forEach(function(mutation)
{
mutation.removedNodes.forEach(function(removedElement)
{
if (removedElement == oldEventListenerKeeper)
{
var newEventListenerKeeper = document.documentElement;
newEventListenerKeeper.addEventListener("keydown", (e)=>console.log(e), false);
oldEventListenerKeeper = newEventListenerKeeper;
}
});
});
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question