forked from enshui/AutoJS_script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
叠蛋糕全自动.js
213 lines (186 loc) · 7.75 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
//速度
var speed = 1;
dialogs.alert("请确认无障碍和悬浮窗权限已开启,感谢使用\n仅供学习参考");
menu: while (true) {
var choose = dialogs.select("请根据你的手机性能(卡不卡)以及网速选择速度", "都挺好的,整个快速的", "一般吧,正常执行就好", "网速有点差,稍微慢点吧", "我手机很砖,整个最慢的吧");
switch (choose) {
case -1:
toast("请选择");
continue menu;
case 0:
toast("即将快速执行脚本");
speed = 0.75;
break menu;
case 1:
toast("即将一般速度执行脚本");
speed = 1;
break menu;
case 2:
toast("即将低速执行脚本");
speed = 1.5;
break menu;
case 3:
toast("即将缓慢执行脚本");
speed = 2;
break menu;
default:
break;
}
}
console.show();
auto.waitFor();
var i = 0;
var j = 0;
sleep(1000);
//打开活动页面
log("正在进入个人中心");
gotoJd();
log("到达任务中心");
//签到
sleep(1000 * speed);
if (text("去签到").exists()) {
text("去签到").findOne().click();
sleep(200 * speed);
log("签到成功")
}
if (text("已签到").exists()) {
sleep(1000 * speed);
log("已签到")
} else {
text("签到").findOne().click();
sleep(1000 * speed);
log("签到成功")
}
sleep(2000 * speed);
//做任务
//获取控件
while (1) {
var a = text("去完成").findOnce(j);
if (a != null) {
//获取父控件
var b = a.parent().parent().parent();
//获取第一个子控件
var c = b.child(0).child(1).text();
if (c.search("8秒") != -1) {
// 8秒任务
i++;
log("开始第" + i + "次去完成");
a.click();
sleep(5000);
textStartsWith("恭喜完成").findOne(8000);
sleep(random(2, 10) * 200 * speed);
back();
log("已完成第" + i + "次!");
sleep(2000 * speed);
j = 0;
} else if (c.search("浏览5个") != -1) {
// 浏览5个商品
i++;
log("开始第" + i + "次去完成");
a.click();
log("开始浏览5个商品任务!");
sleep(random(6, 10) * 200 * speed);
for (var t = 0; t < 5; t++) {
if (textContains("浏览以下").findOnce()) {
log("正在浏览第" + (t + 1) + "个商品!");
idContains("view_").findOnce(t).click();
sleep(random(8, 10) * 200 * speed)
back()
sleep(random(8, 10) * 200 * speed)
} else { }
}
textStartsWith("已完成").findOne(8000);
sleep(random(5, 10) * 200 * speed);
try {
// 点击左上角的返回键
id("fe").findOne().click();
} catch (error) {
back();
}
log("已完成第" + i + "次!");
sleep(2000 * speed);
j = 0;
} else if (c.search("浏览") != -1 && c.search("5个") == -1 && c.search("秒") == -1) {
// 快速浏览
i++;
log("开始第" + i + "次去完成");
a.click();
sleep(1000 * speed);
sleep(random(2, 10) * 200 * speed);
back();
log("已完成第" + i + "次!");
sleep(2000 * speed);
j = 0;
} else if (c.search("去加购") != -1) {
// 去加购商品
i++;
log("开始第" + i + "次去完成");
a.click();
log("开始执行加购任务");
sleep(1000 * speed);
sleep(random(5, 10) * 200 * speed);
for (var t = 0; t < 5; t++) {
//修复加购问题,删掉了.child(2)子节点
idContains("cart_").findOnce(t).click();
sleep(random(5, 10) * 200 * speed)
}
back();
log("已完成第" + i + "次!");
sleep(2000 * speed);
j = 0;
}
else { j++; }
} else {
correct();
}
}
/**
* 纠正方法
*/
function correct() {
log("可能出了点问题,正在尝试第一次纠正");
for (let index = 0; index < 5; index++) {
back();
sleep(1000 * speed);
var d = text("去完成").findOnce(j);
if (d != null) {
return
}
}
if (d == null) {
log("正在尝试第二次纠正");
app.startActivity({
data: "openApp.jdMobile://virtual?params=%7B%22des%22%3A%22m%22%2C%22url%22%3A%22https%3A%2F%2Fbunearth.m.jd.com%2FbabelDiy%2FZeus%2F3xAU77DgiPoDvHdbXUZb95a7u71X%2Findex.html%22%2C%22category%22%3A%22jump%22%2C%22sourceType%22%3A%22JSHOP_SOURCE_TYPE%22%2C%22sourceValue%22%3A%22JSHOP_SOURCE_VALUE%22%2C%22M_sourceFrom%22%3A%22lkyl%22%2C%22msf_type%22%3A%22click%22%2C%22m_param%22%3A%7B%22m_source%22%3A%220%22%2C%22event_series%22%3A%7B%7D%2C%22jda%22%3A%22177095863.1664140455.1538579865.1572975960.1572979455.472%22%2C%22usc%22%3A%22androidapp%22%2C%22ucp%22%3A%22t_335139774%22%2C%22umd%22%3A%22appshare%22%2C%22utr%22%3A%22CopyURL%22%2C%22jdv%22%3A%22177095863%7Candroidapp%7Ct_335139774%7Cappshare%7CCopyURL%7C1572882675599%22%2C%22ref%22%3A%22https%3A%2F%2Fbunearth.m.jd.com%2FbabelDiy%2FZeus%2F3xAU77DgiPoDvHdbXUZb95a7u71X%2Findex.html%22%2C%22psn%22%3A%221664140455%7C472%22%2C%22psq%22%3A5%2C%22pc_source%22%3A%22%22%2C%22mba_muid%22%3A%221664140455%22%2C%22mba_sid%22%3A%221572979455588510925986537476%22%2C%22std%22%3A%22MO-J2011-1%22%2C%22par%22%3A%22%22%2C%22event_id%22%3A%22Mnpm_ComponentApplied%22%2C%22mt_xid%22%3A%22%22%2C%22mt_subsite%22%3A%22%22%7D%2C%22SE%22%3A%7B%22mt_subsite%22%3A%22%22%2C%22__jdv%22%3A%22177095863%7Candroidapp%7Ct_335139774%7Cappshare%7CCopyURL%7C1572882675599%22%2C%22__jda%22%3A%22177095863.1664140455.1538579865.1572975960.1572979455.472%22%7D%7D",
});
log("进入个人中心");
sleep(1000 * speed);
className("android.view.View").text("做任务领金币").waitFor();
sleep(1000 * speed);
if (!textContains("任务每日0点刷新").exists()) {
className("android.view.View").text("做任务领金币").findOne().parent().click()
}
textContains("任务每日0点刷新").waitFor()
sleep(1000 * speed);
var e = text("去完成").findOnce(j);
if (e == null) {
log("貌似没有任务了,脚本退出\n如未完成,请重新运行");
exit();
}
}
}
/**
* 打开京东App并跳转到任务栏
*/
function gotoJd() {
app.startActivity({
data: "openApp.jdMobile://virtual?params=%7B%22des%22%3A%22m%22%2C%22url%22%3A%22https%3A%2F%2Fbunearth.m.jd.com%2FbabelDiy%2FZeus%2F3xAU77DgiPoDvHdbXUZb95a7u71X%2Findex.html%22%2C%22category%22%3A%22jump%22%2C%22sourceType%22%3A%22JSHOP_SOURCE_TYPE%22%2C%22sourceValue%22%3A%22JSHOP_SOURCE_VALUE%22%2C%22M_sourceFrom%22%3A%22lkyl%22%2C%22msf_type%22%3A%22click%22%2C%22m_param%22%3A%7B%22m_source%22%3A%220%22%2C%22event_series%22%3A%7B%7D%2C%22jda%22%3A%22177095863.1664140455.1538579865.1572975960.1572979455.472%22%2C%22usc%22%3A%22androidapp%22%2C%22ucp%22%3A%22t_335139774%22%2C%22umd%22%3A%22appshare%22%2C%22utr%22%3A%22CopyURL%22%2C%22jdv%22%3A%22177095863%7Candroidapp%7Ct_335139774%7Cappshare%7CCopyURL%7C1572882675599%22%2C%22ref%22%3A%22https%3A%2F%2Fbunearth.m.jd.com%2FbabelDiy%2FZeus%2F3xAU77DgiPoDvHdbXUZb95a7u71X%2Findex.html%22%2C%22psn%22%3A%221664140455%7C472%22%2C%22psq%22%3A5%2C%22pc_source%22%3A%22%22%2C%22mba_muid%22%3A%221664140455%22%2C%22mba_sid%22%3A%221572979455588510925986537476%22%2C%22std%22%3A%22MO-J2011-1%22%2C%22par%22%3A%22%22%2C%22event_id%22%3A%22Mnpm_ComponentApplied%22%2C%22mt_xid%22%3A%22%22%2C%22mt_subsite%22%3A%22%22%7D%2C%22SE%22%3A%7B%22mt_subsite%22%3A%22%22%2C%22__jdv%22%3A%22177095863%7Candroidapp%7Ct_335139774%7Cappshare%7CCopyURL%7C1572882675599%22%2C%22__jda%22%3A%22177095863.1664140455.1538579865.1572975960.1572979455.472%22%7D%7D",
});
sleep(1000 * speed);
className("android.view.View").text("做任务领金币").waitFor();
sleep(1000 * speed);
if (!textContains("任务每日0点刷新").exists()) {
className("android.view.View").text("做任务领金币").findOne().parent().click()
}
textContains("任务每日0点刷新").waitFor()
sleep(1000 * speed);
}