Auto-clicker for /r/TheButton
////////////////////////
// READ ME FIRST: https://gist.github.com/jakebathman/804f2b60b3ec915f5a95#file-auto-clicker-for-thebutton-md
////////////////////////
// User variables, which tell the script how often to check The Button
var intClickUnderThisTime = 21000; // Time in milliseconds (seconds x 1000)
var intUpdateFrequency = 100; // Time to check The Button in milliseconds (seconds x 1000)
var boolLogNewLowValue = true; // Log the value of The Button to the console when it reaches a new low (in rounded seconds, using CEILING to round up)
var intLowValue = 60000; // Override this with another value if you know it's been lower
// WARNING: logging this value to the console can be a source of memory leak if this script runs for a long time.
// More on memory leaks in the console from the Chrome dev team: https://developer.chrome.com/devtools/docs/javascript-memory-profiling#memory_mode
var boolLogTicking = false; // Log the value of The Button to the console (in rounded seconds, using CEILING to round up)
// Flair colors, to see what color the press will get you
var arrFlairColors = [
{time:0,color:"????",colorHex:"#000000"},
{time:11,color:"red",colorHex:"#e50000"},
{time:21,color:"orange",colorHex:"#e59500"},
{time:31,color:"yellow",colorHex:"#E5D900"},
{time:41,color:"green",colorHex:"#02be01"},
{time:51,color:"blue",colorHex:"#0083C7"},
{time:60,color:"purple",colorHex:"#820080"},
];
// setTimeout runs a function after a specified amount of time (the function here is called checkButtonTime)
setTimeout(function checkButtonTime(){
// Look at the number of milliseconds left, which is stored in the variable r.thebutton._msLeft
// and compare that to our threshold value stored in intClickUnderThisTime
if(boolLogNewLowValue === true) {
if(r.thebutton._msLeft < intLowValue) {
intLowValue = r.thebutton._msLeft;
var d = new Date();
var strDateTime = (d.getMonth()+1) +"/"+ d.getDate() + " @ " + d.getHours() +":"+ d.getMinutes() +":"+ d.getSeconds();
console.log("NEW LOW VALUE ("+strDateTime+"): " + (r.thebutton._msLeft/1000) + "s");
}
}
if(r.thebutton._msLeft < intClickUnderThisTime){
// The remaining time is under our threshold! Time to click!
// Unlock The Button by removing a CSS class called "locked"
$(".thebutton-container").removeClass("locked")
// Click The Button
$("#thebutton").click();
// See which color flair you earned for that click, by looping over the variable arrFlairColors
var strFlairColorForYou = "grey";
$.each(arrFlairColors,function(k,v){
if (Math.ceil(r.thebutton._msLeft/1000) <= v.time) {
strFlairColorForYou = v.color;
strFlairColorHex = v.colorHex;
return false; // stop this loop from continuing
}
});
// Write a message in the console that the button was clicked
console.log("Under " + intClickUnderThisTime/1000 + " seconds! The Button was clicked at " + r.thebutton._msLeft/1000 + " seconds, and you earned " + strFlairColorForYou + " flair.");
// Change the box around The Button to match your new flair color
$(".thebutton-wrap").prepend("<div style='text-align:center;background-color:"+strFlairColorHex+";color:white;padding:15px;font-size:28px;'>You clicked the button at "+ r.thebutton._msLeft/1000 +" seconds!</div>");
}
else{
// The Button value isn't low enough yet
var strFlairColorAvailable = "grey";
$.each(arrFlairColors,function(k,v){
if (Math.ceil(r.thebutton._msLeft/1000) <= v.time) {
strFlairColorAvailable = v.color;
strFlairColorAvailableHex = v.colorHex;
return false; // stop this loop from continuing
}
});
// If you want "ticking" to be shown in the console, this part does that
if(boolLogTicking === true) {
console.log(Math.ceil(r.thebutton._msLeft/1000) + " ("+strFlairColorAvailable+")"); // Rounded UP, which is how flair is assigned in /r/thebutton
}
setTimeout(checkButtonTime, intUpdateFrequency);
}
},intUpdateFrequency);
###AUTO BUTTON CLICKER
This little script will automatically click The Button (http://www.reddit.com/r/thebutton) when the timer goes below a certain time (set by the user as intClickUnderTime).
This will only run until you refresh the page or navigate away.
:warning: :warning: :warning:
REVIEW THIS CODE CAREFULLY.
It is VERY DANGEROUS to paste code into your browser, as it would allow a nefarious actor to do almost anything you can do in a browser window.
Don't trust me to provide safe code for you to paste. Review it line-by-line.
Read more about these kinds of attacks, and learn to protect yourself:
- Facebook: What is Self-XSS? https://www.facebook.com/help/246962205475854
- Video overview of self-XSS: https://www.facebook.com/photo.php?v=956977232793
- Combating Self-XSS: http://incompleteness.me/blog/2011/12/14/combating-self-xss/
#####To use:
#####CHANGE YOUR MIND?
If you run this code and change your mind about pressing the button, simply REFRESH the page (F5)