Created
April 9, 2015 20:36
-
-
Save Opus1no2/7bd4e9ea148cd6538440 to your computer and use it in GitHub Desktop.
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 (w, $) { | |
$(".btn.play-btn").click(); | |
w.setInterval(run, 500); | |
function clickSpan() { | |
var uniques, | |
trueUnique, | |
spanBackgrounds = []; | |
$("#box span").each(function (s) { | |
spanBackgrounds.push(this.style.background); | |
}); | |
uniques = _.uniq(spanBackgrounds); | |
if (cnt(uniques[0], spanBackgrounds) > 1) { | |
trueUnique = uniques[1]; | |
} else { | |
trueUnique = uniques[0]; | |
} | |
$("#box span[style='background-color: " + trueUnique + ";']").click(); | |
} | |
function cnt(needle, haystack) { | |
return haystack.reduce(function(n, val) { | |
return n + ( val === needle); | |
}, 0); | |
} | |
function run() { | |
if (Number($(".time").text(), 10) > 0) { | |
clickSpan(); | |
} | |
} | |
})(window, jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment