Skip to content

Instantly share code, notes, and snippets.

@sorrycc
Created January 26, 2014 03:10
Show Gist options
  • Save sorrycc/8627815 to your computer and use it in GitHub Desktop.
Save sorrycc/8627815 to your computer and use it in GitHub Desktop.
/**
* @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