Skip to content

Instantly share code, notes, and snippets.

@sbolel
Last active June 4, 2021 20:32
Show Gist options
  • Save sbolel/50afa30c6bd1b2da8e5907f90491b2b7 to your computer and use it in GitHub Desktop.
Save sbolel/50afa30c6bd1b2da8e5907f90491b2b7 to your computer and use it in GitHub Desktop.
(function(_document, key, btn, delay, multiplier){
const _plusOrMinus = () => Math.random() < 0.5 ? -1 : 1
const _randomTimeout = () => (_plusOrMinus() * Math.floor((Math.random() * multiplier))) + delay
this.run = false
const toggle = () => {
this.run = !this.run
if (this.run) setNext()
}
const setNext = () => {
setTimeout(() => {
if (this.run) {
btn.click()
setNext(_randomTimeout())
}
}, _randomTimeout())
}
_document.body.onkeydown = function(e){
if (e.keyCode === key) toggle()
}
})(window.document, 16, $('.recsGamepad__button--like'), 1100, 200)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment