-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy path聚划算定制版本.js
104 lines (102 loc) · 2.56 KB
/
聚划算定制版本.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// var a = text("选择").findOnce()
// if(a){
// a.parent().click();
// }
var page = "";
var retime = 0;
var aheadTime = 500;
var setTimeString = "2019-12-16 16:41:00"
function collectClick(){
while(true){
var a = desc("找相似").findOnce();
if(a){
a.parent().parent().click();
break;
}
}
}
function settle(){
while(true){
var s = textContains("立即购买").findOne();
if(s){
s.click();
}
}
}
function select(){
while(true){
var b = textContains("粉红色").findOnce();
if(b){
b.parent().parent().click();
var a = descContains("256GB").findOnce();
if(a){
a.click();
}
}
}
}
function confirm(){
while(true){
var a = id("confirm").findOne()
if(a){
a.click();
}
}
}
function submit(){
while(true){
var kone = text("提交订单").findOne()
if(kone){
kone.click();
page="提交订单";
break;
}
}
}
function getTime(){
var timestamp1=new Date().getTime()
http.get("http://api.m.taobao.com/rest/api3.do?api=mtop.common.getTimestamp", {}, function(res, err){
var networkTime = parseInt(res.body.json().data.t);
var timestamp2=new Date().getTime();
var reduceTime = (timestamp2 - timestamp1)/2;
var timestamp3=new Date().getTime();
var sjc = networkTime-(timestamp3-reduceTime);//淘宝和本机的时间差
retime = sjc;
toast("本机时间延迟"+sjc+"ms");
toast("网络时延"+reduceTime+"ms");
});
}
function setTime(){
setTimeString = setTimeString.substring(0,19);
setTimeString = setTimeString.replace(/-/g,'/');
setTimeNumber = new Date(setTimeString).getTime();
return setTimeNumber;
}
function start(){
getTime();
var ti = setTime()-aheadTime;
toast("开始准备抢购:"+setTimeString+"提前:"+aheadTime+"ms");
while(true){
var thisTime = new Date().getTime()-retime;
if(thisTime>ti){
toast("开始抢购");
threads.start(function(){
collectClick();
})
threads.start(function(){
select();
})
threads.start(function(){
confirm();
})
threads.start(function(){
settle();
})
threads.start(function(){
submit();
})
break;
}
}
}
start();