Last active
August 29, 2015 14:08
-
-
Save 4lun/ee0cb0534b5507c117f8 to your computer and use it in GitHub Desktop.
Cheat for http://colorrun.pl/ (run in the console after starting) :P
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 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