Skip to content

Instantly share code, notes, and snippets.

@colinodell
Created April 1, 2015 17:45
Show Gist options
  • Save colinodell/497ccfd9aa9a6370129d to your computer and use it in GitHub Desktop.
Save colinodell/497ccfd9aa9a6370129d to your computer and use it in GitHub Desktop.
/r/thebutton
// Super-simple console script to push the button only when the timer gets low
var h;
var armed = false;
var lowestSoFar = 9999999999;
h = setInterval(function() {
if (r.thebutton._msLeft <= 0) {
console.log('Game over :-/');
clearInterval(h);
return;
}
if (r.thebutton._msLeft < lowestSoFar) {
lowestSoFar = r.thebutton._msLeft;
console.log('New low: ' + lowestSoFar / 1000 + ' seconds');
}
// Arm the button with 10 seconds left
if (!armed && r.thebutton._msLeft < 10000) {
$("#thebutton").parent().trigger('click');
armed = true;
console.log('BUTTON IS ARMED - READY FOR CLICK')
}
// Click the button with 5 seconds left
if (r.thebutton._msLeft < 5000) {
$("#thebutton").trigger('click');
console.log('CLICKED!');
}
}, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment