Last active
August 29, 2015 14:19
-
-
Save weatherglass/1884758f271a8bee3672 to your computer and use it in GitHub Desktop.
This file contains 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
(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