-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhtt.js
477 lines (313 loc) · 12.7 KB
/
htt.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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
/*
稳
公众号iosrule by红鲤鱼与绿鲤鱼与驴
2020.6.27
#惠头条签到定时执行任务,因为有阅读,视频和小视频三个奖励,建议2分钟以上频率.
1.2020627完成签到奖励,时段奖励,阅读奖励
2.2020628增加观视频奖励,小视频奖励,首页奖励,每日阅读资讯领金币
3.20200629修复每日任务的阅读资讯领金币待测试,首页奖励无法代码实现。加关闭任务通知功能。
4.20200630修复bug
问题:如果日志出现提示登录状态失效之类,点阅读软件首页时段奖励按钮获取ck。
圈叉,sugar用户自己定时,本代码通用。
loon定时格式参考
cron "0 0/2 * * * ?" script-path=htt_task.js, tag=惠头条
*/
//以上是配置说明
const Notice=5;//设置运行多少次才通知。
const log=0;//设置0关闭日志,1开启日志
//====================================
const $iosrule = iosrule();//声明必须
const httid="A";
const huitoutiao="惠头条";
//++++++++++++++++++++++++++++++++-
const htt_videoname="htt_videoname"+httid;
const htt_video=$iosrule.read(htt_videoname);
console.log(htt_video);
const htt_dongfangname="htt_dongfangname"+httid;
const htt_dongfang=$iosrule.read(htt_dongfangname);
console.log(htt_dongfang);
const htt_smvideoname="htt_smvideoname"+httid;
const htt_smvideo=$iosrule.read(htt_smvideoname);
console.log(htt_smvideo);
const htt_signurlckname="htt_signurlckname"+httid;
const htt_signurlck=$iosrule.read(htt_signurlckname);
console.log(htt_signurlck);
const htt_signbdname="htt_signbdname"+httid;
const htt_signbd=$iosrule.read(htt_signbdname);
console.log(htt_signbd);
var htt_num=0;var htt_result="";
//++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++++++
//3.需要执行的函数都写这里
function main()
{
htt_main();
}
function htt_main()
{
htt_coinall();
}
main()
//++++++++++++++++++++++++++++++++++++
//4.基础模板
function htt_taskread5()
{
var result1="【每日任务阅读奖励】";var result2="";
var tt=huitoutiao;
var htt_signbd_task=JSON.parse(htt_signbd);
htt_signbd_task.taskId=5;
const llUrl1 = {url:"https://api.cashtoutiao.com/frontend/daily/task/revision/draw?"+htt_signurlck,headers:{"Content-Type":"application/json","User-Agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 12_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"},body:htt_signbd_task,timeout:60};
$iosrule.post(llUrl1, function(error, response, data) {
if(log==1) console.log(data)
var obj=JSON.parse(data);
if(obj.statusCode==200)
result2="💰[金币]"+obj.reward;
else if(obj.statusCode==-50)
result2="重复领取.🐜";
htt_msg(result1+"\n"+result2+"\n");
})
}
function htt_daysign()
{
var result1="";var result2="";
var tt=huitoutiao;
const llUrl1 = {url:"https://api.cashtoutiao.com/frontend/sign?"+htt_signurlck,headers:{"Content-Type":"application/json","User-Agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 12_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"},body:htt_signbd};var signjs=JSON.parse(htt_signbd);signjs["code"]=sign("%3Dhdfefni");const llUrl2 = {url:"https://api.cashtoutiao.com/frontend/invite?"+htt_signurlck,headers:{"Content-Type":"application/json","User-Agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 12_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"},body:signjs};
$iosrule.post(llUrl1, function(error, response, data) {
if(log==1) console.log(data)
var obj=JSON.parse(data)
if(obj.statusCode==200)
{result2="💰[金币]"+obj.signCredit;
htt_signday(result2);}
else if(obj.statusCode==-50)
{result2="[重复签到]";
htt_signday(result2);}})
$iosrule.post(llUrl2, function(error, response, data){})}
function htt_hoursign()
{
var result1="【时段奖励】";var result2="";
var tt=huitoutiao;
const llUrl1 = {url:"https://api.cashtoutiao.com/frontend/credit/sych/reward/per/hour?"+htt_signurlck,headers:{"Content-Type":"application/json","User-Agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 12_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"},body:htt_signbd,timeout:60};
$iosrule.post(llUrl1, function(error, response, data) {
if(log==1)console.log(data)
var obj=JSON.parse(data);
if(obj.statusCode==200)
result2="💰[金币]"+obj.credit;
else if(obj.statusCode==-50)
result2=obj.msg;
if(result2.indexOf("频繁")>0)
result2="重复领取🐜";
htt_msg(result1+"\n"+result2+"\n");
})
}
function htt_signday(res)
{
var result1="【签到奖励】";var result2="";
var tt=huitoutiao;
const llUrl1 = {url:"https://api.cashtoutiao.com/frontend/sign/record?"+htt_signurlck,headers:{"Content-Type":"application/json","User-Agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 12_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"},body:htt_signbd,timeout:60};
$iosrule.post(llUrl1, function(error, response, data) {
if(log==1) console.log(data)
var obj=JSON.parse(data)
if(obj.statusCode==200)
result2=res+" ✍🏻️[签到天数]"+obj.day;
htt_msg(result1+"\n"+result2+"\n");
})
}
function htt_read_dongfang()
{
var result1="【阅读奖励】";var result2="";
var tt=huitoutiao;
const llUrl1 = {url:"https://api.cashtoutiao.com/frontend/read/sych/duration?"+htt_signurlck,headers:{"Content-Type":"application/json","User-Agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 12_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"},body:htt_find(htt_dongfang),timeout:60};
$iosrule.post(llUrl1, function(error, response, data) {
if(log==1)console.log("阅读"+data)
var obj=JSON.parse(data)
if(obj.statusCode==200)
{if(data.indexOf("失败")<0)
{result2="💰[金币]"+obj.incCredit+" [今日阅读时长]"+formatSeconds(obj.todayDuration);}
else
{
result2=obj.msg;
if(result2.indexOf("稍后")>0)
result2="阅读间隔不达标,自动跳过。✌🏻️";
result1="【阅读奖励失败】"
}
htt_msg(result1+"\n"+result2+"\n");}
})
}
function htt_read_video()
{
var result1="【看视频奖励】";var result2="";
var tt=huitoutiao;
const llUrl1 = {url:"https://api.cashtoutiao.com/frontend/read/sych/duration?"+htt_signurlck,headers:{"Content-Type":"application/json","User-Agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 12_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"},body:htt_find(htt_video),timeout:60};
$iosrule.post(llUrl1, function(error, response, data) {
if(log==1)console.log("视频"+data)
var obj=JSON.parse(data)
if(obj.statusCode==200)
{if(data.indexOf("失败")<0)
{result2="💰[金币]"+obj.incCredit+" [今日看视频时长]"+formatSeconds(obj.todayDuration);
}
else
{
result2=obj.msg; if(result2.indexOf("稍后")>0)
result2="视频间隔不达标,自动跳过。✌🏻️";
result1="【看视频奖励失败】"
}
}
else
result2="请求失败*";
htt_msg(result1+"\n"+result2+"\n");
})
}
function htt_read_smvideo()
{
var result1="【看小视频奖励】";var result2="";
var tt=huitoutiao;
const llUrl1 = {url:"https://api.cashtoutiao.com/frontend/read/sych/duration?"+htt_signurlck,headers:{"Content-Type":"application/json","User-Agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 12_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"},body:htt_find(htt_smvideo),timeout:60};
$iosrule.post(llUrl1, function(error, response, data) {
if(log==1)console.log("小视频"+data)
var obj=JSON.parse(data)
if(obj.statusCode==200)
{if(data.indexOf("失败")<0)
{result2="💰[金币]"+obj.incCredit+" [今日看小视频时长]"+formatSeconds(obj.todayDuration);
}
else
{
result2=obj.msg; if(result2.indexOf("稍后")>0)
result2="小视频间隔不达标,自动跳过。✌🏻️";
result1="【看小视频奖励失败】"
}
}
else
result2="请求失败*";
htt_msg(result1+"\n"+result2+"\n");
})
}
function htt_readtotal()
{
var result1="【收益统计】";var result2="";
var tt=huitoutiao;
const llUrl1 = {url:"https://api.cashtoutiao.com/frontend/read/detail/today?"+htt_signurlck,headers:{"Content-Type":"application/json","User-Agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 12_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"},body:htt_signbd,timeout:60};
$iosrule.post(llUrl1, function(error, response, data) {
var obj=JSON.parse(data)
if(obj.statusCode==200)
{result2=
"[总金币]"+obj.userDailyReadRecord.durationCredit+"💰 "+formatSeconds(obj.userDailyReadRecord.totalDuration)+"\n"+
"[观看视频]"+obj.userDailyReadRecord.videoDurationCredit+"💰"+formatSeconds(obj.userDailyReadRecord.videoDuration)+"\n"+
"[观看小视频]"+obj.userDailyReadRecord.smallVideoDurationCredit+"💰"+formatSeconds(obj.userDailyReadRecord.smallVideoDuration)+" "
+"\n"+
"[分享收益]"+obj.userDailyReadRecord.shareClickCredit+"💰";
htt_msg(result1+"\n"+result2+"\n");
;}})
}
function htt_msg(r)
{var tt=huitoutiao;
htt_num++;htt_result+=r;
if(log==1)console.log(htt_num)
if(htt_num==7)
{var loon= $iosrule.read("iosrule");
console.log(loon);
if (typeof(loon) !="undefined")
{loon=loon.substring(7,loon.length);
loon++;
console.log("惠头条第"+loon+"次运行");$iosrule.write("iosrule"+loon,"iosrule");}else{loon=1;
$iosrule.write("iosrule"+loon,"iosrule")
} if (loon%Notice==0)
{papa(tt,"[签到-时段-视频-阅读]"+"当前运行"+loon+"次",htt_result);loon=0;$iosrule.write("iosrule"+loon,"iosrule");loon=0; htt_result ="";$iosrule.write("iosrule"+loon,"iosrule");
}
}
}
function htt_coinall()
{
setTimeout(function(){
htt_daysign();
}, 1* 100);
setTimeout(function(){
htt_hoursign();
htt_taskread5();
}, 5* 100);
setTimeout(function(){
htt_read_dongfang();
}, 6* 100);
setTimeout(function(){
htt_read_video();
}, 32* 1000);
setTimeout(function(){
htt_read_smvideo();
}, 63* 1000);
setTimeout(function(){
htt_readtotal();
}, 64* 1000);
}
function htt_find(bd) {
if(JSON.parse(bd).hasOwnProperty("token"))
{bd=JSON.parse(bd);delete bd["token"];bd=JSON.stringify(bd);
return bd;}
else
return bd;
}
function
formatSeconds(value) {
let result = parseInt(value)
let h = Math.floor(result / 3600) < 10 ? '0' + Math.floor(result / 3600) : Math.floor(result / 3600);
let m = Math.floor((result / 60 % 60)) < 10 ? '0' + Math.floor((result / 60 % 60)) : Math.floor((result / 60 % 60));
let s = Math.floor((result % 60)) < 10 ? '0' + Math.floor((result % 60)) : Math.floor((result % 60));
let res = '';
if(h !== '00') res += `${h}小时`;
if(m !== '00') res += `${m}分`;
res += `${s}秒`;
return res;
}
function papa(x,y,z){
$iosrule.notify(x,y,z);}
function sign(code)
{
code=unescape(code);
var c=String.fromCharCode(code.charCodeAt(0)-code.length);
for(var i=1;i<code.length;i++){
c+=String.fromCharCode(code.charCodeAt(i)-c.charCodeAt(i-1));
}
return c;
}
function iosrule() {
const isRequest = typeof $request != "undefined"
const isSurge = typeof $httpClient != "undefined"
const isQuanX = typeof $task != "undefined"
const notify = (title, subtitle, message) => {
if (isQuanX) $notify(title, subtitle, message)
if (isSurge) $notification.post(title, subtitle, message)
}
const write = (value, key) => {
if (isQuanX) return $prefs.setValueForKey(value, key)
if (isSurge) return $persistentStore.write(value, key)
}
const read = (key) => {
if (isQuanX) return $prefs.valueForKey(key)
if (isSurge) return $persistentStore.read(key)
}
const get = (options, callback) => {
if (isQuanX) {
if (typeof options == "string") options = { url: options }
options["method"] = "GET"
$task.fetch(options).then(response => {
response["status"] = response.statusCode
callback(null, response, response.body)
}, reason => callback(reason.error, null, null))
}
if (isSurge) $httpClient.get(options, callback)
}
const post = (options, callback) => {
if (isQuanX) {
if (typeof options == "string") options = { url: options }
options["method"] = "POST"
$task.fetch(options).then(response => {
response["status"] = response.statusCode
callback(null, response, response.body)
}, reason => callback(reason.error, null, null))
}
if (isSurge) $httpClient.post(options, callback)
}
const end = () => {
if (isQuanX) isRequest ? $done({}) : ""
if (isSurge) isRequest ? $done({}) : $done()
}
return { isRequest, isQuanX, isSurge, notify, write, read, get, post, end }
};