Created
October 1, 2014 11:45
-
-
Save kolyuchii/d791e89eff7e38791d50 to your computer and use it in GitHub Desktop.
Helper for game.ioxapp.com/color/
This file contains hidden or 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
| 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