抖音极速版邀请码: 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 }
