-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path聚划算.js
349 lines (331 loc) · 10.6 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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
/**
*京东年货节活动脚本
*参考脚本改编,原脚本为:淘宝+京东双十一活动脚本
*可访问:Github: https://github.com/hyue418
*感谢Hyue418大佬的原脚本
*小小耀
*/
//无障碍判定
try {
auto();
} catch (error) {
toast("请手动开启无障碍并授权给Auto.js");
sleep(2000);
exit();
}
//初始化参数
versions = 'V2.5.0';
speed = 1;
float = 1.25;
patNum = 0;
swipeTips = "滑啊滑啊滑啊滑ヽ( ̄▽ ̄)ノ";
taskChooseList = ["聚划算"];
speedChooseList = [0.75, 1, 1.25, 1.5, 1.75, 2, 3];
taobaoActivityData = "taobao://m.tb.cn/h.4NvBF6z?sm=fd5d9f";
alipaysActivityData = "alipays://platformapi/startapp?appId=68687502";
width = device.width;
height = device.height;
setScreenMetrics(width, height);
alert("【聚划算 " + versions + "】", "脚本执行过程请勿手动点击屏幕,否则脚本执行可能会错乱,导致任务失败\n执行过程中可按音量+键终止\n参考脚本改编,原脚本为:淘宝+京东双十一活动脚本\n可访问:Github: https://github.com/hyue418\n年货节脚本访问:\n");
//选择任务
taskChoose();
/**
* 任务选择
*/
function taskChoose() {
var options = dialogs.multiChoice("需要执行的任务", taskChooseList);
if (options == '') {
toastLog("脚本已退出");
exit();
}
//勾选调速时弹出速度选择
options.indexOf(4) > -1 && speedChoose();
runOptions(options);
}
/**
* 速度选择
*/
function speedChoose() {
var option = dialogs.singleChoice("操作间隔的倍数(越大越慢)", speedChooseList, 1);
if (option == -1) {
toastLog("脚本已退出");
exit();
}
speed = speedChooseList[option];
}
/**
* 执行选中任务
* @param options 选项数组
*/
function runOptions(options) {
console.show();
log("聚划算" + versions + "\n");
log("脚本执行期间请勿手动点击按钮");
log("当前脚本操作时间间隔为【" + speed + "倍】");
options.forEach(option => {
switch (option) {
case 0:
//执行淘宝任务
var taskList = ['签到', '去完成'];
log("=====开始执行" + taskChooseList[option] + "=====");
runTaobao("手机淘宝", taobaoActivityData, taskList);
break;
default:
break;
}
});
alert("任务已完成", "所有任务貌似都做完啦!\n若仍有任务请重新运行噢!\n\nGitHub: https://github.com/hyue418\nPowered By Hyue418");
}
/**
* 淘宝活动脚本,兼容淘宝&支付宝
* @param appName
* @param activityData
* @param taskList
*/
function runTaobao(appName, activityData, taskList) {
var i = j = 0;
toastLog("打开【" + appName + "】活动页");
app.startActivity({
action: "VIEW",
data: activityData
});
randomSleep(6500);
taskList.forEach(task => {
while (textContains(task).exists()) {
var button = text(task).findOnce(j);
if (button == null) {
break;
}
log("开始做第" + (i + 1) + "次任务");
switch (task) {
case '去搜索':
case '逛一逛':
case '去完成':
log("开始【" + task + "】任务");
clickButton(button);
randomSleep(500);
//若未点击成功,则再次点击
while (textContains(task).exists()) {
clickButton(button);
randomSleep(300);
}
randomSleep(2500);
if (textContains("复制链接").exists()) {
log("跳过分享任务");
j++;
i++;
back();
randomSleep(200);
back();
break;
}
randomSleep(2500);
if (text("取消").findOne()) {
log("跳过天猫下载任务");
j++;
i++;
randomSleep(1200);
back();
randomSleep(1200);
back();
randomSleep(200);
back();
break;
}
if (textContains("淘宝特价版送红包").exists()) {
log("跳过打开APP任务");
j++;
i++;
back();
break;
}
toast(swipeTips);
randomSwipe();
randomSleep(5000);
toast(swipeTips);
randomSwipe();
randomSleep(6000);
toast(swipeTips);
randomSwipe();
descContains("任务完成").findOne(8000 * speed);
randomSleep(1000);
i++;
log("已完成");
back();
//支付宝任务返回后需要点击确认按钮
if (appName == '支付宝') {
randomSleep(2000);
clickContent('好的,我知道了');
}
break;
case '去观看':
case '去浏览':
log("开始【" + task + "】任务")
clickButton(button);
randomSleep(500);
//若未点击成功,则再次点击
while (textContains(task).exists()) {
clickButton(button);
randomSleep(300);
}
randomSleep(3500);
if (textContains("观看").exists() && textContains("关注").exists()) {
//进入直播页面直接等待,不滑屏
randomSleep(18000);
} else {
toast(swipeTips);
randomSwipe();
randomSleep(3500);
toast(swipeTips);
randomSwipe();
randomSleep(5500);
toast(swipeTips);
randomSwipe();
}
textContains("全部完成").findOne(8000 * speed);
randomSleep(1000);
i++;
log("已完成")
back();
break;
case '领取奖励':
case '签到':
log("跳过");
case '领取':
clickButton(button);
randomSleep(1500);
log("【" + task + "】成功")
//支付宝任务签到后需要点击确认按钮
if (appName == '支付宝') {
clickContent('好的,我知道了');
}
break;
default:
log("跳过");
break;
}
randomSleep(2000);
}
});
toastLog("【" + appName + "】任务已完成");
log("=========================");
}
/**
* 通过文字内容模拟点击按钮
* @param content 按钮文字内容
* @param type 点击类型,默认为text点击
* @param sleepTime 等待时间,默认1000毫秒
*/
function clickContent(content, type, sleepTime) {
var type = type || "text";
var sleepTime = sleepTime || 1000;
sleep(sleepTime * float * speed);
if (type == "text") {
var button = text(content).findOne();
} else {
var button = desc(content).findOne();
}
clickButton(button);
return button;
}
/**
* 根据控件的坐标范围随机模拟点击
* @param button
*/
function clickButton(button) {
var bounds = button.bounds();
press(random(bounds.left, bounds.right), random(bounds.top, bounds.bottom), random(50, 100));
}
/**
* 根据控件的坐标范围随机模拟点击(京东用)
* 京东任务按钮有圆角,通用的随机点击方法容易点出圆角外导致点击失效,此处做修正
* @param button
*/
function jdClickButton(button) {
var bounds = button.bounds();
var width = bounds.right - bounds.left;
var high = bounds.top - bounds.bottom;
press(random(bounds.left + width / 4, bounds.right - width / 4), random(bounds.top + high / 3, bounds.bottom - high / 3), random(50, 100));
}
/**
* 根据float倍数sleep随机时间
* @param time
*/
function randomSleep(time) {
sleep(ramdomByFloat(time) * speed);
}
/**
* 随机滑动
*/
function randomSwipe() {
smlMove(ramdomByFloat(width / 2), ramdomByFloat(height / 1.5), ramdomByFloat(width / 2), ramdomByFloat(height / 4), ramdomByFloat(800));
}
/**
* 范围随机数生成
* @param min
* @param max
*/
function random(min, max) {
return Math.round(Math.random() * (max - min)) + min;
}
/**
* 根据float生成随机数
* @param number
*/
function ramdomByFloat(number) {
return random(number, number * float);
}
/**
* 仿真随机带曲线滑动
* @param qx 起点x轴坐标
* @param qy 起点y轴坐标
* @param zx 终点x轴坐标
* @param zy 终点y轴坐标
* @param time 滑动时间,毫秒
*/
function smlMove(qx, qy, zx, zy, time) {
var xxy = [time];
var point = [];
var dx0 = {
"x": qx,
"y": qy
};
var dx1 = {
"x": random(qx - 100, qx + 100),
"y": random(qy, qy + 50)
};
var dx2 = {
"x": random(zx - 100, zx + 100),
"y": random(zy, zy + 50),
};
var dx3 = {
"x": zx,
"y": zy
};
for (var i = 0; i < 4; i++) {
eval("point.push(dx" + i + ")");
}
;
for (let i = 0; i < 1; i += 0.08) {
xxyy = [parseInt(bezierCurves(point, i).x), parseInt(bezierCurves(point, i).y)];
xxy.push(xxyy);
}
gesture.apply(null, xxy);
};
function bezierCurves(cp, t) {
cx = 3.0 * (cp[1].x - cp[0].x);
bx = 3.0 * (cp[2].x - cp[1].x) - cx;
ax = cp[3].x - cp[0].x - cx - bx;
cy = 3.0 * (cp[1].y - cp[0].y);
by = 3.0 * (cp[2].y - cp[1].y) - cy;
ay = cp[3].y - cp[0].y - cy - by;
tSquared = t * t;
tCubed = tSquared * t;
result = {
"x": 0,
"y": 0
};
result.x = (ax * tCubed) + (bx * tSquared) + (cx * t) + cp[0].x;
result.y = (ay * tCubed) + (by * tSquared) + (cy * t) + cp[0].y;
return result;
};