Skip to content

Instantly share code, notes, and snippets.

@kevcenteno
Last active August 29, 2015 14:07
Show Gist options
  • Save kevcenteno/53ec1ba8144caab37e04 to your computer and use it in GitHub Desktop.
Save kevcenteno/53ec1ba8144caab37e04 to your computer and use it in GitHub Desktop.
(function () {
var cheatDelay = 1000; //set how fast you want to cheat
var cheat = function () {
var boxArr, tempColor, i, $firstBox, $tempBox;
boxArr = $('#box').find('span');
$firstBox = $(boxArr[0]);
$firstBox.click(); //just click the first box in case it's the win
tempColor = $firstBox.css('background-color');
for (i = 1; i < boxArr.length; i++) {
$tempBox = $(boxArr[i]);
if ( $tempBox.css('background-color') === tempColor ) continue;
else $tempBox.click(); return;
}
};
//let's use MutationObserver
var boxEl = document.querySelector('#box');
var observer = new MutationObserver(function(mutations) {
if (mutations) setTimeout(cheat, cheatDelay);
});
var mutationConfig = { attributes: true };
observer.observe(boxEl, mutationConfig);
})();
@vbarinov
Copy link

Hey! Nice script 👍

Here is mine https://gist.github.com/vbarinov/e4f321a0832c21cf6f45

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment