Repository navigation
Expand file tree
/
Copy pathcloud-music.js
More file actions
78 lines (76 loc) · 3.22 KB
/
Copy pathcloud-music.js
File metadata and controls
78 lines (76 loc) · 3.22 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
// ----------------------------
// 脚本信息设定
let task_name = "网易云音乐签到";
let app_name = "网易云音乐";
// ----------------------------
let common = require('common.js');
common.startLog(task_name);
common.runApp(app_name);
// ----------------------------
// 脚本自定义函数
getDailyPoints();
// ----------------------------
common.stopApp(app_name);
common.endLog(task_name);
home();
exit();
function getDailyPoints() {
let detect_drawer_menu_button = common.detectWidgetItem("desc", "抽屉菜单", "error", "normal");
if (detect_drawer_menu_button) {
detect_drawer_menu_button.click();
let detect_points_center_button = common.detectWidgetItem("textContains", "云贝中心", "error", "normal");
if (detect_points_center_button) {
detect_points_center_button.parent().parent().click();
if (common.detectSuccessInfo("textContains", "云贝账单")) {
console.log("已进入云贝中心");
console.log("已领取「签到的云贝」");
// 目前的版本中,text 的末尾含有空格,为避免这种状况,将 text 选择器换为 textContains 选择器
let detect_points_from_listening_music = textContains("听音乐30分钟").find();
let detect_points_from_listening_podcast = textContains("听播客30秒").find();
let try_time = 0;
while (detect_points_from_listening_music.empty()) {
sleep(100);
detect_points_from_listening_music = textContains("听音乐30分钟").find();
try_time++;
if (try_time > 50) {
common.detectWidgetItemLog("log", "听音乐30分钟", 50);
break;
}
}
while (detect_points_from_listening_podcast.empty()) {
sleep(100);
detect_points_from_listening_podcast = textContains("听播客30秒").find();
try_time++;
if (try_time > 50) {
common.detectWidgetItemLog("log", "听播客30秒", 50);
break;
}
}
if (detect_points_from_listening_music.nonEmpty()) {
detect_points_from_listening_music.forEach(function (element) {
recursiveClick(element);
sleep(1000);
}
);
console.log("已领取「听音乐的云贝」");
}
if (detect_points_from_listening_podcast.nonEmpty()) {
detect_points_from_listening_podcast.forEach(function (element) {
recursiveClick(element);
sleep(1000);
}
);
console.log("已领取「听播客的云贝」");
}
}
else {
console.error("未能进入云贝中心");
}
}
}
}
function recursiveClick(element) {
if (element != null)
if (!element.click())
recursiveClick(element.parent());
}