Skip to content

Instantly share code, notes, and snippets.

@zeppelin
Created April 11, 2015 12:12
Show Gist options
  • Save zeppelin/22e6cb17b1fe5ac75d67 to your computer and use it in GitHub Desktop.
Save zeppelin/22e6cb17b1fe5ac75d67 to your computer and use it in GitHub Desktop.
Maxing out Kuku Kube - http://106.186.25.143/kuku-kube/en-3/
new MutationObserver(function() {
var slotA = {
count: 0,
color: null,
element: null
};
var slotB = {
count: 0,
color: null,
element: null
};
var tiles = document.querySelectorAll('#box > span');
for (var i = 0, len = tiles.length; i < len; i++) {
var tile = tiles[i];
var color = tile.style.backgroundColor;
var targetSlot = (!slotA.color || slotA.color === color) ? slotA : slotB;
targetSlot.count++;
targetSlot.color = color;
targetSlot.element = tile;
if ((slotA.count > 1 && slotB.count === 1) || (slotA.count === 1 && slotB.count > 1)) {
var result = (slotA.count > slotB.count) ? slotB : slotA;
setTimeout(function() {
result.element.click();
}, 0);
break;
}
}
}).observe(document.querySelector('#box'), {
attributes: true
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment