首页 > 代码库 > 小米自动砸蛋机器js代码

小米自动砸蛋机器js代码

02 //地址:http://static.xiaomi.cn/515
03 //@author:liuzh
04 //@url:http://blog.csdn.net/isea533
05 var start = 10000000;
06 var autoEgg = {
07     start:function(){
08         //5秒发布一次
09         setInterval(this.send,5000);
10         //5秒点击一次
11         setTimeout(this.egg,5000);
12         //3秒检测一下关闭
13         setInterval(this.close,3000);
14     },
15     send:function(){
16         //填写内容
17         document.getElementById(‘commentContent‘).value = http://www.mamicode.com/start++;
18         //发布
19         $(‘#sentBtn‘).click();
20     },
21     close:function(){
22         if($(‘.unlucky_egg_modal‘).hasClass(‘in‘) || $(‘.unlucky_egg_modal‘).css(‘display‘)==‘block‘){
23             $(‘a.close‘).click();
24         }
25     },
26     egg:function(){
27         //随机敲蛋
28         $(‘.egg‘)[(Math.random()*3).toFixed(0)].click();
29         setTimeout(function(){
30             if($(‘.unlucky_egg_modal‘).hasClass(‘in‘) || $(‘.unlucky_egg_modal‘).css(‘display‘)==‘block‘){
31                 setTimeout(this.egg,1000);
32             }
33             else {
34                 alert(‘提示!‘);
35             }
36         },3000);
37     }
38 }
39 //开始
40 autoEgg.start();