Skip to content

Instantly share code, notes, and snippets.

@4lun
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 4lun/ee0cb0534b5507c117f8 to your computer and use it in GitHub Desktop.
Save 4lun/ee0cb0534b5507c117f8 to your computer and use it in GitHub Desktop.
Cheat for http://colorrun.pl/ (run in the console after starting) :P
function hackThePlanet() {
var colors = document.querySelectorAll('.color'),
values = [];
for(var i = 0; i < colors.length; i++) {
var rgb = colors[i].style.backgroundColor;
values[i] = 0;
rgb.replace(/[^\d,]+/g, '')
.split(',')
.forEach(function(j) {
values[i] += +j;
});
}
var largest = Math.max.apply(Math, values),
index = values.indexOf(largest),
target = colors[index];
console.log(values, index);
target.click();
}
setInterval(hackThePlanet, 50);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment