Skip to content

Instantly share code, notes, and snippets.

@MightyAlex200
Created August 14, 2017 04:36
Show Gist options
  • Save MightyAlex200/e73560209e9016ee89bfa096ce0a1255 to your computer and use it in GitHub Desktop.
Save MightyAlex200/e73560209e9016ee89bfa096ce0a1255 to your computer and use it in GitHub Desktop.
// 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