Skip to content

Instantly share code, notes, and snippets.

@alessioalex
Last active June 2, 2023 17:08
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save alessioalex/fc536ef87713d0a9ed89 to your computer and use it in GitHub Desktop.
Save alessioalex/fc536ef87713d0a9ed89 to your computer and use it in GitHub Desktop.
intercept *.addEventListener for debugging
// http://stackoverflow.com/questions/4787698/failure-to-override-elements-addeventlistener-in-firefox
(function() {
Error.stackTraceLimit = Infinity;
var _interfaces = Object.getOwnPropertyNames(window).filter(function(i) {
return /^HTML/.test(i);
}).map(function(i) {
return window[i];
});
// var _interfaces = [ HTMLDivElement, HTMLImageElement, HTMLUListElement, HTMLElement, HTMLDocument ];
for (var i = 0; i < _interfaces.length; i++) {
(function(original) {
_interfaces[i].prototype.addEventListener = function(type, listener, useCapture) {
console.log('addEventListener ' + type, listener, useCapture);
console.trace();
console.log('--------');
return original.apply(this, arguments);
}
})(_interfaces[i].prototype.addEventListener);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment