Created
August 14, 2017 04:36
-
-
Save MightyAlex200/e73560209e9016ee89bfa096ce0a1255 to your computer and use it in GitHub Desktop.
Flippy bit bot (http://flippybitandtheattackofthehexadecimalsfrombase16.com/)
This file contains hidden or 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
// To use, paste this into the console in devtools on flippy bit website, then type `setInterval(pressButtons, 1)` | |
// Fails at ~350 because at around 100 score the game spawns an enemy every frame | |
function findEnemies() { | |
let rval = []; | |
for(c of game.children) { | |
if(c.id.startsWith("enemy")){rval.push(c)}; | |
} | |
return rval; | |
} | |
function getButtons() { | |
let enemies = findEnemies(); | |
let target = enemies.find(e => !e.getAttribute("class").includes("under-attack")); | |
if(target) { | |
let rval = parseInt(target.getAttribute("data-nr")).toString(2).split('').map(n => n == '1'); | |
while(rval.length < 8) { | |
rval.unshift(false); | |
} | |
return rval; | |
} | |
} | |
function pressButtons() { | |
buttons = getButtons(); | |
if(buttons) { | |
for(i in buttons) { | |
if(buttons[i]) { | |
$("html").trigger(jQuery.Event('keypress', {keyCode: (i+1).charCodeAt(0)+1})); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment