Created
March 25, 2020 18:30
-
-
Save RichardMarks/62ce98cf653b722743013fe0525ce016 to your computer and use it in GitHub Desktop.
clearTimers Chrome Snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
if (window.clearTimers) { | |
console.log('clearTimers snippet already available. execute "clearTimers()" in your console.') | |
return | |
} | |
const clearTimers = () => { | |
try { | |
const noop = () => {} | |
const nextId = setTimeout(noop) | |
const startTime = (new Date()).getTime() | |
console.log('clearing timers...please wait') | |
for (let i = 1; i < nextId; i++) { | |
clearTimeout(i) | |
const currentTime = (new Date()).getTime() | |
if (currentTime - startTime > 60000) { | |
console.log('clearing timers - took too long, bailing out') | |
break | |
} | |
} | |
console.log('cleared timers') | |
} catch (err) { | |
console.error(err) | |
} | |
} | |
window.clearTimers = clearTimers | |
console.log('clearTimers snippet installed. execute "clearTimers()" in your console.') | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment