forked from maxwellyue/autojs_script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path芝麻头条.js
124 lines (103 loc) · 2.39 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
const utils = require('common.js');
utils.wakeUp();
utils.launch("芝麻头条");
//睡眠15s
sleep(15000);
/**
* 所有的控件ID
*/
var xwid = "tv_title";//新闻标题的id,每次更新都会变更
var btm1 = "tab_news";//底部1 新闻
//开始刷新闻,主循环
jumpToIndex();
while(true){
//领取时段奖励
getAward();
//点击进入新闻
getOneNews();
//阅读新闻60s
readNews(60);
//返回新闻列表
backToIndex();
}
//跳转到首页
function jumpToIndex(){
//领取奖励
var awardBtn = id("tv_draw_bonuses").findOnce();
if(awardBtn){
awardBtn.click();
}
//跳转到首页
id(btm1).click();
}
//领取时段奖励
function getAward(){
//自动领取时段奖励
// var textOk = id("ll_timing").findOnce();
// if(textOk){
// textOk.click();
// }
}
// 获取一条新闻
var lastNewsText="";//上一次新闻标题
var totalNews = 0;
function getOneNews(){
/**
* 阅读超过50条,刷新页面
*/
if(totalNews > 50){
totalNews = 0;
//刷新
var refresh = id(btm1).findOnce();
if(refresh){
refresh.click();
sleep(2000);
}
}
/**
* 上滑找新闻
*/
var newsItem = false;
var loopTime = 0;//循环次数
var newsText = "";//新闻标题
while((!newsItem || lastNewsText === newsText) && loopTime < 20){
loopTime++;
//进行下翻
swipe(device.width / 2, device.height / 4 * 2,
device.width / 2, device.height / 4, 1000);
sleep(1000);
//找到阅读次数,这个是正规的新闻
newsItem = id(xwid).findOnce(1);
newsText = newsItem.text();
}
/**
* 找到新闻
*/
if(newsItem){
lastNewsText = newsText;
totalNews++;
}else{
toast("20次滑动没有找到新闻,请检查新闻ID");
exit();
}
utils.boundsClick(newsItem);
return newsItem;
}
//阅读新闻
function readNews(seconds){
var times = seconds/5;
//开始滑动
for(var i = 1;i < times;i++){
swipe(device.width / 2, device.height / 5 * 3,
device.width / 2, device.height / 4 * 1, 5000);
}
}
//回到主页面
function backToIndex(){
var indexBtn = false;
while(!indexBtn){
back();
sleep(500);
indexBtn = id(btm1).findOnce();
}
}