Skip to content

Instantly share code, notes, and snippets.

@RichardMarks
Created March 25, 2020 18:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RichardMarks/62ce98cf653b722743013fe0525ce016 to your computer and use it in GitHub Desktop.
Save RichardMarks/62ce98cf653b722743013fe0525ce016 to your computer and use it in GitHub Desktop.
clearTimers Chrome Snippet
(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