抖音極速版邀請碼: 890992808
其實我是想寫簽到、日常任務和寶箱的,結果寶箱我一直找到find的方法。有會的朋友告訴一下,小弟謝過!
說明一個事情:抖音極速版在不同的分辨率下顯示的UI部局不一樣,我下面的代碼可能在5寸屏幕有問題,因為元素不一樣。
直接代碼:
1 auto.waitFor();
2 app.launchApp('抖音極速版');
3 sleep(6000);
4 console.show(); //開啟日志(懸浮窗權限)31 31 17
5 youngWin();
6 let ImageView = className("android.widget.ImageView").depth(3).find();
7 if (ImageView.length == 3) {
8 ImageView[0].click();
9 sleep(3000);
10 if (className("android.view.View").text("去領取").exists()) {
11 console.log("抖音去領取");
12 let b = text("去領取").findOne().bounds();
13 click(b.centerX(), b.centerY());
14 sleep(25000);
15 if (className("android.widget.textView").text("關閉廣告").exists()){
16 className("android.widget.textView").text("關閉廣告").findOne().click();
17 }
18 }
19 swipe(device.width / 2, device.height - 200, device.width / 2, 500, 700);
20 if (text("去查看").exists()) {
21 console.log("抖音去查看");
22 let b = text("去查看").findOne().bounds();
23 click(b.centerX(), b.centerY());
24 }
25 }
26 sleep(10000);
27 //關閉當前程序
28 console.hide();
29 home();
30 exit();
31 /**
32 * 屏幕向下滑動並延遲8至12秒
33 */
34 function slideScreenDown(startX, startY, endX, endY, pressTime) {
35 swipe(startX, startY, endX, endY, pressTime);
36 let delayTime = random(8000, 12000);
37 sleep(delayTime);
38 }
39 /**如果彈出青少年窗口,點擊 */
40 function youngWin() {
41 if (youngWin = text("我知道了").exists()) {
42 console.log("點擊了我知道了(青少年窗口)");
43 youngWin.click();
44 };
45 }
46 /**
47 * 隨機上滑(防止被判定是機器)上滑后停留時間至少是10S,造成假象表示是對內容感興趣
48 * 點贊和關注先不搞。
49 */
50 function randomUpSildeScreen() {
51 let randomIndex = random(1, 40);
52 if (randomIndex == 1) {
53 console.log("隨機上滑被執行了");
54 pressTime = random(200, 500);
55 swipe(device.width / 2, 500, device.width / 2, device.height - 200, 700);
56 delayTime = random(10000, 15000);
57 sleep(delayTime);
58 }
59 }
60 /**
61 * 連續下滑對上一個無興趣
62 * 其實得和上滑做個排他,既然無興趣不要在上滑
63 */
64 function randomDownSildeScreen() {
65 let randomIndex = random(1, 50);
66 if (randomIndex == 1) {
67 console.log("連續下滑被執行了");
68 swipe(device.width / 2, device.height - 200, device.width / 2, 500, 700);
69 sleep(2000);
70 swipe(device.width / 2, device.height - 200, device.width / 2, 500, 700);
71 delayTime = random(8000, 10000);
72 sleep(delayTime);
73 }
74 }
75
76 /**隨機點贊並休息一秒 */
77 function randomHeart() {
78 index = random(1, 50);
79 if (index == 6) {
80 var target = id('a4l').findOnce();
81 if (target == null) {
82 return;
83 } else {
84 target.click();
85 sleep(1000);
86 console.log("隨機點贊並休息一秒");
87 }
88 }
89 }
90 /**
91 * 隨機關注
92 */
93 function randomFollow() {
94 index = random(1, 100);
95 if (index == 66) {
96 var target = id('a4j').findOnce();
97 if (target == null) {
98 return;
99 } else {
100 target.click();
101 sleep(1000);
102 console.log("隨機關注並休息一秒");
103 }
104 }
105
106 }
