Skip to content

Instantly share code, notes, and snippets.

@shiburagi
Last active August 18, 2021 08:35
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 shiburagi/232df516b1959bda737c5e16ce530a76 to your computer and use it in GitHub Desktop.
Save shiburagi/232df516b1959bda737c5e16ce530a76 to your computer and use it in GitHub Desktop.
fn=(delay=5,rands=[20,10,15])=>{
if(!loop) return;
console.log("click")
document.dispatchEvent(new Event('keydown', {keyCode: 'a'}))
setTimeout(fn, rands.reduce((s,v)=>s+Math.random()*v) +5);
}
startFn=()=>{
loop = true
fn()
}
stopFn=()=>{
loop =false
}
startFn()
@shiburagi
Copy link
Author

shiburagi commented Aug 18, 2021

stop : stopFn()

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