Created
February 2, 2015 08:32
-
-
Save taichunmin/2bcaf66dcfa8f5427b98 to your computer and use it in GitHub Desktop.
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
// http://game.ioxapp.com/color/ | |
function fa($obj) { | |
$obj.click(); | |
} | |
setInterval(function(){ | |
var $target = [], bgcolor = []; | |
$("#box span").each(function(i){ | |
switch($target.length) { | |
case 0: // 初始狀態 | |
$target[0] = $(this); | |
bgcolor[0] = $target[0].css('background-color'); | |
state = 1; | |
break; | |
case 1: // 已儲存 1 個 | |
var $this = $(this); | |
if( bgcolor[0] != $this.css("background-color") ){ | |
if(i > 1) { | |
fa($this); | |
return false; | |
} | |
$target[1] = $this; | |
bgcolor[1] = $this.css("background-color"); | |
state = 2; | |
} | |
break; | |
case 2: // 已儲存 2 個 | |
var $this = $(this); | |
if( bgcolor[0] == $this.css("background-color") ) | |
fa($target[1]); | |
else fa($target[0]); | |
return false; | |
break; | |
} | |
}); | |
} , 5); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment