Created
April 10, 2015 13:25
-
-
Save lupos/891513cf9c30bbcfd573 to your computer and use it in GitHub Desktop.
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 solve = function () { | |
| var items = $("#box span"), | |
| firstItemCss = $(items[0]).css("background-color"), | |
| group1 = [], | |
| group2 = [], | |
| resolve = false; | |
| if ( items.length > 0 ){ | |
| resolve = true; | |
| } | |
| for ( var i = 0, length = items.length; i < length; i++){ | |
| if ( i === 0 ) { | |
| group1.push(items[i]); | |
| } else { | |
| if ( $(items[i]).css("background-color") !== firstItemCss ){ | |
| group2.push(items[i]); | |
| } else { | |
| group1.push(items[i]); | |
| } | |
| } | |
| } | |
| if ( group1.length > group2.length ){ | |
| $(group2[0]).click(); | |
| } else { | |
| $(group1[0]).click(); | |
| } | |
| //run it again | |
| window.setTimeout(function () { | |
| if (resolve){ | |
| solve(); | |
| } else { | |
| console.log("done"); | |
| } | |
| }, 10) //the 10 is how long it waits before trying to click again. 10milliseconds. You can try and make this number smaller but the speed of the computer/ browser affects how hard you can push it before its waisting cycles. My top score is 5322 with this script | |
| } | |
| solve(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment