Skip to content

Instantly share code, notes, and snippets.

@andydavies
Created February 9, 2021 15:23
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andydavies/a54e8785ee91c694ff070347a5756036 to your computer and use it in GitHub Desktop.
Save andydavies/a54e8785ee91c694ff070347a5756036 to your computer and use it in GitHub Desktop.
DevTools snippet to remove the document contents and any event handlers on document and window objects
document.documentElement.innerHTML = '';
for (const obj of [document, window]) {
for (const event of Object.values(getEventListeners(obj))) {
for (const {type, listener, useCapture} of event) {
obj.removeEventListener(type, listener, useCapture)
}
}
}
@andydavies
Copy link
Author

for (const obj of [document, window]) {
for (const event of Object.values(getEventListeners(obj))) {
for (const {type, listener, useCapture} of event) {
console.log(type, listener, useCapture)
}
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment