Created
May 29, 2015 00:29
-
-
Save mreis1/b3bf1d50e72e5e5c71b7 to your computer and use it in GitHub Desktop.
kuku-kube
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
/** | |
Quick hack for kube-kube by mreis1 | |
http://106.186.25.143/kuku-kube/en-3/ | |
open the console: | |
1. copy the code below and paste on it; | |
2. press enter; | |
3. copy and paste this: solvePuzzle().trigger('click') | |
4. paste is as many times as you want to keep gaining points | |
*/ | |
var solvePuzzle = (function(){ | |
return solvePuzzle; | |
function solvePuzzle(){ | |
var colors = {}; | |
$b = $('#box');$b.find('span').each(function(){ | |
var style = $(this).attr('style'); | |
colors[style] = colors[style] ? colors[style] = colors[style]+1 : 1; | |
colors[style] = colors[style]; | |
}) | |
var style = getBigger(colors); | |
return $b.find('span').filter(function(item){ | |
if ($(this).attr('style')==style) { return $(this)}; | |
}) | |
} | |
function getBigger(colors){ | |
var prev = false; | |
var prevKey = false; | |
$.each(colors ,function(key, item){ | |
if (!prev){ | |
prev = colors[key]; prevKey = key; | |
} else { | |
if (prev > item){ | |
prev = item; prevKey = key; | |
} | |
} | |
}) | |
return prevKey; | |
} | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment