Last active
August 29, 2015 14:15
-
-
Save edward-hsu-1994/a0de9dae3f43d67d475b 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
//程式世界(https://www.facebook.com/ProgramingTech) | |
//THE COLOR遊戲,自動點擊(http://game.ioxapp.com/color/) | |
var timer; | |
function C(){ | |
var Temp = {};//空物件 | |
$("#box").find("span").each(function(){ | |
var color = $(this).css('backgroundColor');//取得背景色 | |
var stop = $(this).css('display');//取得顯示 | |
if(stop == "none"){//如果不顯示則表示遊戲結束 | |
clearInterval(timer);//清除Timer | |
console.log("stop!"); | |
return; | |
} | |
if(!Temp[color])Temp[color]=0;//如果顏色尚未紀錄,則新增一筆且值為0 | |
Temp[color] += 1;//將顏色的累計次數+1 | |
}); | |
for(var item in Temp){//將所有顏色列舉檢查 | |
if(Temp[item] != 1)continue;//如果累積次數不是一次就不是目標 | |
$("#box").find("span").each(function(){//將目前box內的span列舉比對 | |
var color = $(this).css('backgroundColor');//取得背景色 | |
if(color == item){//比對 | |
$(this).click();//顏色相等時按下按鈕 | |
} | |
}); | |
} | |
} | |
function Start(speed){//MaxSpeed = 1; | |
if(!speed)speed = 1000;//Def Value; | |
console.log(speed); | |
timer = setInterval(C, speed); | |
$(".play-btn").click();//Start! | |
} | |
function Stop(){ | |
clearInterval(timer);//清除Timer | |
} | |
Start(500);//TEST |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment