Skip to content

Instantly share code, notes, and snippets.

@weatherglass
Last active August 29, 2015 14:19
Show Gist options
  • Save weatherglass/1884758f271a8bee3672 to your computer and use it in GitHub Desktop.
Save weatherglass/1884758f271a8bee3672 to your computer and use it in GitHub Desktop.
(function(){
// Set this to be the time you want the button clicked at
var click_at = 1;
// Convert click_at to milliseconds.
// Thanks to http://www.reddit.com/user/rec0rder for the fact that
// the button always rounds the ms up to get your click time.
click_at *= 1000;
// Get time of last server tick
var tick = r.thebutton._tickTime;
// Start trying to click...
var btnInt = setInterval(
function () {
// If the server tick hasn't changed, wait...
if ( tick == r.thebutton._tickTime) {
return;
}
// The connection is live. Get the number of ms left on the timer
var ms = r.thebutton._msLeft;
// Is it time to click?
if ( ms <= click_at ) {
// Yes!! Unlock and click that button!
$('.thebutton-container').removeClass('locked').addClass('unlocked');
$('#thebutton').click();
// Let me know we're now a button clicker
console.log('clicked button at', ms);
// Stop trying to push the button
clearInterval(btnInt);
} else {
// Not yet. Show me what the timer says
console.log(ms);
}
// Update the server tick time that we tried to press the button
tick = r.thebutton._tickTime;
},
100 // Try ten times per second
);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment