forked from Zebartin/autoxjs-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path积分兑换.js
More file actions
82 lines (80 loc) · 2.33 KB
/
Copy path积分兑换.js
File metadata and controls
82 lines (80 loc) · 2.33 KB
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
auto.waitFor();
var {
unlockIfNeed,
requestScreenCaptureAuto,
ocrUntilFound,
clickRect,
getDisplaySize
} = require('./utils.js');
let [width, height] = getDisplaySize();
unlockIfNeed();
requestScreenCaptureAuto();
app.launchApp('哔哩哔哩漫画');
// 找到“我的”按钮
let myBtn = ocrUntilFound(res => {
let t = res.filter(e => e.text == '我的').toArray();
if (t.length == 0)
return null;
if (t.length == 1)
return t[0];
t.sort((a, b) => a.bounds.top - b.bounds.top);
return t[t.length - 1];
}, 20, 3000);
sleep(2000);
back();
clickRect(myBtn);
clickRect(ocrUntilFound(res => res.find(e => e.text.match(/(分[商高])/) != null), 10, 700));
let targetName = '【超特惠】';
let costPoint = 100;
let hourNow = new Date().getHours();
if (hourNow == 9 || hourNow == 10) {
targetName = '【特惠】';
costPoint = 300;
}
const firstSelector = className("android.widget.TextView").textContains(targetName).depth(11);
const confirmSelector = className("android.widget.TextView").textEndsWith(`${costPoint} 积分兑换`).depth(12);
firstSelector.waitFor();
const matched = textStartsWith('赛季积分').findOne().text().match(/季[积枳]+分[::\s]*(\d+)/);
const remainPoint = matched ? parseInt(matched[1]) : 0;
log(`赛季积分:${remainPoint}`);
let firstButton = null;
if (remainPoint >= costPoint) {
for (let i = 0; i < 100; ++i) {
firstButton = firstSelector.findOne().parent().child(2);
if (firstButton.text() != '抢光了')
break;
swipe(width / 2, height / 2, width / 2, height * 0.8, 500);
sleep(random(2000, 3000));
}
if (firstButton.text() == '抢光了')
exit();
var threadClose = threads.start(() => {
const closeSelector = text("关闭").depth(11);
while (true) {
closeSelector.waitFor();
remainPoint -= costPoint;
closeSelector.click();
while (closeSelector.exists())
sleep(100);
}
});
while (remainPoint >= costPoint) {
firstButton = firstSelector.findOne().parent().child(2);
if (firstButton.text() == '抢光了') {
log('抢光了');
break;
}
firstButton.click();
confirmSelector.click();
while (confirmSelector.exists())
sleep(100);
}
threadClose.interrupt();
}
for (let i = 0; i < 4; ++i) {
back();
sleep(500);
}
if (images.stopScreenCapturer) {
images.stopScreenCapturer();
}