Skip to content

Instantly share code, notes, and snippets.

@justinledwards
Created September 13, 2023 12:43
Show Gist options
  • Save justinledwards/93c1f0267383451558ae071b3d913987 to your computer and use it in GitHub Desktop.
Save justinledwards/93c1f0267383451558ae071b3d913987 to your computer and use it in GitHub Desktop.
Snake cheat
let e=e=>new Promise(t=>setTimeout(t,e)),c=e=>e.charCodeAt(),a=e=>"Arrow"+e,k=e=>{let t=new KeyboardEvent("keydown",{key:e,code:e,keyCode:c(e),which:c(e)});document.dispatchEvent(t)},t=(t,o)=>e(t).then(()=>k(a(o))),l=async()=>{for(let e=0;e<1e9;e++)await t(30,"Left"),await t(720,"Up"),await t(30,"Right"),await t(780,"Up")};e(90).then(l);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment