Skip to content

Instantly share code, notes, and snippets.

@orrybaram
Last active August 29, 2015 14:18
Show Gist options
  • Save orrybaram/a4cd246868ba5d130615 to your computer and use it in GitHub Desktop.
Save orrybaram/a4cd246868ba5d130615 to your computer and use it in GitHub Desktop.
The button clicker and logger
var ButtonHaxor = (function() {
// Set to what you want the button to be clicked on
var CLICK_ON_SCORE = 1;
var interval = null;
var low_score = 60;
var clicked_score = 60;
var times_clicked = 0;
// Elements
var $BUTTON = window.document.getElementById('thebutton');
var $SHIELD = window.document.getElementsByClassName('thebutton-container')[0];
var $tens = window.document.getElementById('thebutton-s-10s');
var $ones = window.document.getElementById('thebutton-s-1s');
var purps = [];
var blues = [];
var greens = [];
var yellows = [];
var oranges = [];
var reds = [];
var sheild_clicked = false;
var button_clicked = false;
interval = setInterval(function() {
var timer = parseInt($tens.innerHTML + $ones.innerHTML);
var color = 'red';
if (clicked_score < timer) {
console.log('clicked @%c' + clicked_score + 's', 'padding:2px; border-radius:2px;color: white; background-color:' + getColor(clicked_score));
clicked_score = 60;
} else {
clicked_score = timer;
}
if (timer < low_score) {
low_score = timer;
console.log('All time low! === ' + low_score + ' @ ' + new Date());
}
if(timer < CLICK_ON_SCORE + 1) {
console.log('SHIELD REMOVED!');
if(!shield_clicked) {
$SHIELD.click();
shield_clicked = true
}
}
if(timer < CLICK_ON_SCORE) {
if(!button_clicked) {
$BUTTON.click();
console.log('OMG I CLICKED IT!!!!!!');
button_clicked = true;
clearInterval(interval);
}
}
}, 17);
function getColor(timer) {
var color = 'gray';
if (timer > 50) {
purps.push({secs: timer, time: new Date() });
color = '#820080'
} else if (timer > 40) {
blues.push({secs: timer, time: new Date() });
color = '#0083C7'
} else if (timer > 30) {
greens.push({secs: timer, time: new Date() });
color = '#02BE01'
} else if (timer > 20) {
yellows.push({secs: timer, time: new Date() });
color = '#E5D900'
} else if (timer > 10) {
oranges.push({secs: timer, time: new Date() });
color = '#e59500'
} else if (timer > 0) {
reds.push({secs: timer, time: new Date() });
color = '#E50000'
}
return color;
}
var getStats = function() {
return {
lowest: low_score,
purps: purps.length,
blues: blues.length,
greens: greens.length,
yellows: yellows.length,
oranges: oranges.length,
reds: reds.length
}
}
return {
getStats: getStats,
purps: purps,
blues: blues,
greens: greens,
yellows: yellows,
oranges: oranges,
reds: reds
}
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment