Created
April 1, 2015 17:45
-
-
Save colinodell/497ccfd9aa9a6370129d to your computer and use it in GitHub Desktop.
/r/thebutton
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
// 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