Skip to content

Instantly share code, notes, and snippets.

@Opus1no2
Created April 9, 2015 20:36
Show Gist options
  • Save Opus1no2/7bd4e9ea148cd6538440 to your computer and use it in GitHub Desktop.
Save Opus1no2/7bd4e9ea148cd6538440 to your computer and use it in GitHub Desktop.
(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