Skip to content

Instantly share code, notes, and snippets.

@amit08255
Forked from alessioalex/debug-events.js
Created August 18, 2022 12:28
Show Gist options
  • Save amit08255/d29e04061cc4be0e219269f3a87d199f to your computer and use it in GitHub Desktop.
Save amit08255/d29e04061cc4be0e219269f3a87d199f 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