Skip to content

Instantly share code, notes, and snippets.

@andydavies
Created February 9, 2021 15:23
Show Gist options
  • Select an option

  • Save andydavies/a54e8785ee91c694ff070347a5756036 to your computer and use it in GitHub Desktop.

Select an option

Save andydavies/a54e8785ee91c694ff070347a5756036 to your computer and use it in GitHub Desktop.

Revisions

  1. andydavies created this gist Feb 9, 2021.
    9 changes: 9 additions & 0 deletions cleanPage.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    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)
    }
    }
    }