Created
January 26, 2014 03:10
-
-
Save sorrycc/8627815 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/** | |
* @ref: http://static.xiaomi.cn/2014tv/index.html | |
*/ | |
var g_count = 0; | |
var za = function() { | |
console.log("砸了" + (++g_count) + "次"); | |
var index = Math.floor(Math.random()*3) + 1; | |
$("div.egg-" + index)[0].click(); | |
}; | |
var zan = function() { | |
var zanEl = $("a.js-event-vote")[0]; | |
zanEl.click(); | |
}; | |
var again = function() { | |
var againEl = $("a.btn-again")[0]; | |
againEl.click(); | |
}; | |
var result = function() { | |
var stage2El = $("#stage2"); | |
var stage3El = $("#stage3"); | |
if (stage3El.css("display") === "block") { | |
alert("中奖了"); | |
return; | |
} | |
if (stage2El.css("display") === "block") { | |
again(); | |
setTimeout(run); | |
return; | |
} | |
setTimeout(result, 1000); | |
}; | |
var run = function() { | |
zan(); | |
setTimeout(za, 1000); | |
setTimeout(result, 3000); | |
}; | |
run(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment