Created
April 11, 2015 12:12
-
-
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/
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
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