Skip to content

Instantly share code, notes, and snippets.

@mreis1
Created May 29, 2015 00:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mreis1/b3bf1d50e72e5e5c71b7 to your computer and use it in GitHub Desktop.
Save mreis1/b3bf1d50e72e5e5c71b7 to your computer and use it in GitHub Desktop.
kuku-kube
/**
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