-
Notifications
You must be signed in to change notification settings - Fork 303
/
Copy path京东签到.js
63 lines (55 loc) · 1.48 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
require("./解锁.js");
let Robot = require("./lib/Robot.js");
let WidgetAutomator = require("./lib/WidgetAutomator.js");
let OcrTool = require("./lib/OcrTool.js");
let robot = new Robot();
let widget = new WidgetAutomator(robot);
let ocrTool = new OcrTool();
toastLog("京东签到");
// 启动APP
widget.launchLikeName("京东", 8000);
// 切换到我的
widget.clickCenterDesc("我的");
sleep(2000);
// 关闭弹窗
if (desc("关闭按钮").exists()) {
desc("关闭按钮").click();
}
// 进入签到
widget.clickCenterText("签到领豆");
sleep(10000);
// 点击签到
let flag = false;
ocrTool.prepare(false);
for (let i = 0;i < 3;i++) {
flag = false;
let tpl = ocrTool.captureAndClip([0, 0, 1080, 900]);
let keywords = ["去登录", "明天", "赚更多京豆", "签到领豆"];
let result = ocrTool.findText(tpl, keywords, true);
if (result[0].length > 0) {
robot.click(result[0][0], result[0][1]);
toastLog("点击登录");
sleep(1000);
continue;
}
if ((result[1].length > 0)|| (result[2].length > 0)) {
toastLog("已签");
break;
} else if (result[3].length > 0) {
robot.click(result[3][0], result[3][1]);
toastLog("签到成功");
sleep(1500);
break;
} else {
flag = true;
toastLog("失败,重试");
}
}
if (flag) exit();
// 关闭应用
robot.close();
sleep(500);
// 锁定
if (text("屏幕锁定").exists()) {
widget.clickText("屏幕锁定");
}