Skip to content

Instantly share code, notes, and snippets.

@kolyuchii
Created October 1, 2014 11:45
Show Gist options
  • Select an option

  • Save kolyuchii/d791e89eff7e38791d50 to your computer and use it in GitHub Desktop.

Select an option

Save kolyuchii/d791e89eff7e38791d50 to your computer and use it in GitHub Desktop.
Helper for game.ioxapp.com/color/
var f = function () {
var box = document.querySelector('#box');
var cubes = box.querySelectorAll('span');
var el = null;
for(var i = 0, l = cubes.length; i < l; i += 1) {
if (el === null) {
el = cubes[i];
} else if (convert(el.style.backgroundColor) < convert(cubes[i].style.backgroundColor)) {
c(cubes[i]);
return false;
}
}
function convert (rgb) {
return rgb.replace(/[^0-9,]/g, '').split(',').reduce(function (summ, item) {
return ~~summ + ~~item;
});
}
c(el);
};
var c = function (el) {
el.click();
setTimeout(f, 200);
};
f();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment