-
Notifications
You must be signed in to change notification settings - Fork 227
/
趣头条.js
264 lines (243 loc) · 7.5 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
/**
* 1元起提,没有限制,只要求手机验证码
*/
const deviceHeight=device.height
const deviceWidth=device.width
const halfDeviceHeight=deviceHeight/2
const halfDeviceWidth=deviceWidth/2
const readTotalNum=20//需要阅读20篇
const perNewsReadTime=30//每篇文章阅读时长s
// test()
// onlyRun()
//只允许本脚本时,将上行解除注释
function onlyRun(){
auto();
console.show()
log("开始刷趣头条")
let totalTime=2*60*60 //刷2小时
run(totalTime)
}
var quTouTiao = {};
quTouTiao.main = function (totalTime) {
run(totalTime)
};
module.exports = quTouTiao;
function test(){
watchSmallVideo()
exit();
}
function run(totalTime){
launchApp()
device.setBrightness(0)//设置屏幕亮度
readNews(totalTime/2);
watchSmallVideo(totalTime/2)
// watchVideo()
}
function launchApp(){
try {
launchPackage("com.jifen.qukan")
sleep(3000)
text("我的").waitFor()
log("已启动")
} catch (error) {
log("启动失败,再次启动")
sleep(1000)
launchApp()
}
}
function readNews(totalTime){
log("开始刷头条")
//点击“看点”
click(100,deviceHeight-200)
sleep(2000)
let readResule={
readTime:0,
readCount:0
}
while(totalTime>readResule.readTime||readTotalNum>readResule.readCount){
let thisReadResule=readCurrentScreenNews()
readResule.readTime+=thisReadResule.readTime
readResule.readCount+=thisReadResule.readCount
swipe(deviceWidth/2, deviceHeight-300, deviceWidth/2, deviceHeight-(deviceHeight-70), 1500)//上滑x
sleep(3000)
log("累计阅读文章数量"+readResule.readCount+"阅读时间"+readResule.readTime)
}
}
// 阅读当前屏幕显示的新闻,返回阅读时长和数量
function readCurrentScreenNews(){
let readResule={
readTime:0,
readCount:0
}
let newsTitleArray=getCurrentScreenNews()
log("当前页面新闻数量:"+newsTitleArray.length)
for(let i=0;i<=newsTitleArray.length;i++){
if(newsTitleArray[i]==undefined){
log("当前屏幕文章已经阅读完")
return readResule
}
let NewsIndexFrame=getNewsFrameIndexTitleUi(newsTitleArray[i])
if(NewsIndexFrame==null)continue
let newsReadResule=readNewsIndexTitleUi(NewsIndexFrame)
readResule.readTime+=newsReadResule.readTime
readResule.readCount+=newsReadResule.readCount
log("当前屏幕阅读文章数量"+readResule.readCount+"阅读时间"+readResule.readTime)
// isHanveQiandaoBox()
}
return readResule
}
function readVideo(){
}
//找出当前页面所有文章的标题
function getCurrentScreenNews(){
// let newsTitleArray= id("com.jifen.qukan:id/amd").find()
let newsTitleArray= id("com.jifen.qukan:id/an2").find()
return newsTitleArray;
}
//阅读一篇文章,传入文章的title的控件对象
function readNewsIndexTitleUi(NewsIndexFrame){
NewsIndexFrame.click();
sleep(1000)
text("我来说两句...").waitFor()
// let isHanveIncome=id("com.jifen.qukan:id/bnj").findOnce()//是否有收益图标
// if(!isHanveIncome){
// log("没有收益图标")
// sleep(1000)
// newsBack()
// return{
// readTime:0,
// readCount:0
// }
// }
sleep(1000)
randomSwipeIndexDirection(1)//先往下滑1下,启动计时
let readTime=randomSwipe(perNewsReadTime)
newsBack()
return{
readTime:readTime,
readCount:1
}
}
function newsBack(){
let isHomePage=null
while(!isHomePage){
log("尝试返回")
back()
sleep(2000)
isHomePage=text("小视频").findOnce()
}
log("返回成功")
}
//传入文章的title的控件对象,返回文章的可点击对象frame
function getNewsFrameIndexTitleUi(titleUi){
let frame=titleUi
while(!frame.clickable()){
frame=frame.parent()
if(frame==null){
log("没有可点击的框架"+titleUi.text())
return null
}
}
// log("找到了")
return frame
}
//随机滑动指定的时间
function randomSwipe(indexTime){
let intervalTime=6//5秒
for(let useTime=0;useTime<indexTime;useTime+=intervalTime){
sleep(intervalTime*1000)
log("已观看:"+useTime+"/"+indexTime)
let direction=random(-1,1)
direction=direction==0?1:direction;
randomSwipeIndexDirection(direction)
let replay= text("重播").findOnce()
if(replay!=null){
log("视频已经看完")
return useTime;
}
//ToDo 1圈金币翻倍卡
}
return indexTime
}
//随机滑动,指定方向,-1为向上滑,1为上滑
function randomSwipeIndexDirection(direction){
let swipeDistance=150//1次滑150px
let offset=random(-100,100)
swipe(halfDeviceWidth-random(-100,100), halfDeviceHeight+offset+(swipeDistance/2*direction),
halfDeviceWidth+random(-100,100), halfDeviceHeight+offset-(swipeDistance/2*direction), 500);
//ToDo 1圈金币翻倍卡
}
//是否有签到提醒
function isHanveQiandaoBox(){
let qiandao=text("每天提醒签到赚金币,连续签到").findOnce()
if(qiandao){
log("有签到提醒")
// id("com.xiangzi.jukandian:id/iv_cancel").click()
sleep(1000)
}
}
///////////////////////////////////////
function watchSmallVideo(totalTime){
log("开始看视频")
text("小视频").findOne().click()
let perVideoWatchTime=10
let totalWatchTime=1*3600//1小时
let watchTime=0
for(let i=0;i<totalTime/perVideoWatchTime;i++){
// let isIncome=isNoIncome()
// if(!isIncome){
// log("没有收益了,结束运行")
// runOver()
// }
sleep(3000)
let isAd=text("查看详情").findOnce()
if(!isAd){
let waitTime=perVideoWatchTime-3+random(-5,5)//减去之前休息的上3000毫秒
log("本条视频观看时长"+waitTime)
sleep((waitTime-5)*2*1000);
likeAndfollow(2)
sleep(5*2*1000);
watchTime+=waitTime
log("已累计观看时长"+watchTime+"秒")
}else{
let isFuli=text("广告").findOnce()
if(isFuli){
//如果是惊喜福利限时领则不管
}else{
//正常广告
sleep(18000);
}
}
swipeVideo()
}
}
function swipeVideo(){
let videoSwipeDistance=device.height-650//视频下滑的长度 px
let offset=random(-100,0)
swipe(halfDeviceWidth+random(-100,100), halfDeviceHeight+offset+(videoSwipeDistance/2),
halfDeviceWidth+random(-100,100), halfDeviceHeight+offset-(videoSwipeDistance/2), 500);
sleep(1000)
}
//有range*2+1分之一的概率点喜欢,range*4+1分之一的概率点关注,关注必定喜欢
function likeAndfollow(range){
let isLike=random(-1*range,range)
if(isLike==0){
click(halfDeviceWidth,halfDeviceHeight)
sleep(50)
click(halfDeviceWidth,halfDeviceHeight)
log("双击喜欢")
let isFollow=random(-1*range,range)
if(isFollow==0){
id("com.jifen.qukan:id/s_").click()
log("点了关注")
}else{
log("不是点关注的概率:"+isFollow)
}
}else{
log("不是点喜欢的概率:"+isLike)
}
}
function watchVideo(){
text("视频").click()
sleep(2000)
}