Created
May 24, 2019 09:01
-
-
Save nitobuendia/20264fd1375fb9465d420fede4281bb1 to your computer and use it in GitHub Desktop.
Colors of the Wind - Kube-Kube AutoWin
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
/** | |
* Clicks the different colored tile. | |
* Wins the game on https://kuku-kube.com/ | |
* To use, simply start the game and paste this code on | |
* the JavaScript console. | |
*/ | |
const clickBoxColor = () => { | |
let lastColor; | |
const boxes = document.querySelectorAll('#box span'); | |
for (let i = 0; i < boxes.length; i++) { | |
const box = boxes[i]; | |
const bgColor = box.style.backgroundColor; | |
if (!lastColor) { | |
lastColor = bgColor; | |
continue; | |
} | |
if (lastColor === bgColor) { | |
continue; | |
} else { | |
// Current and last color are different. | |
if (i > 1) { | |
// If it is not the second element, at least two were the same color. | |
// Hence, it is safe to click this one. | |
box.click(); | |
} else { | |
// If it is the second element, we need to check a third color to | |
// decide which one is the different one. | |
const nextBox = boxes[2]; | |
const nextBoxBgColor = nextBox.style.backgroundColor; | |
if (lastColor === nextBoxBgColor) { | |
boxes[1].click(); | |
} else { | |
boxes[0].click(); | |
} | |
} | |
} | |
} | |
}; | |
// Clicks every 250 miliseconds. | |
// Change to increase or decrease frequency. | |
setInterval(clickBoxColor, 250); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment