forked from heiwoya/JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ydd.js
1105 lines (1000 loc) · 44.7 KB
/
ydd.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
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
IOS:看点宝/阅多多/悦看点
三个APP分别捉包,可以共用一个脚本跑任务
比较容易黑,不要跑太频繁,每天11次就可以领完任务奖励
每天金币7毛以上,提现1元和5元需要做任务拿提现券
看点宝下载注册地址:https://yuekandian.yichengw.cn/download?app=5&referrer=764084
可以在环境变量yddSkipWithdraw设置不想提现的金额,逗号隔开,填0就会尝试提现所有金额
export yddSkipWithdraw='1'
青龙:
捉取 https://yuekandian.yichengw.cn/api/v1/member/profile 的包里的Authorization(把前面的Bearer删掉),device和User-Agent,按顺序用#连起来写到yddCookie里,多账户用@隔开
export yddCookie='账号1的Authorization#device#UA@账号2的Authorization#device#UA'
V2P重写:打开APP即可获取CK,没有的话点一下我的页面或者赚钱页面
[task_local]
#看点宝/阅多多/悦看点
15 9-21 * * * https://raw.githubusercontent.com/leafxcy/JavaScript/main/ydd.js, tag=看点宝/阅多多/悦看点, enabled=true
[rewrite_local]
https://yuekandian.yichengw.cn/api/v1/member/profile url script-request-header https://raw.githubusercontent.com/leafxcy/JavaScript/main/ydd.js
[MITM]
hostname = yuekandian.yichengw.cn
*/
const jsname = '阅多多'
const $ = Env(jsname)
const notifyFlag = 1; //0为关闭通知,1为打开通知,默认为1
const logDebug = 0
//const notify = $.isNode() ? require('./sendNotify') : '';
let notifyStr = ''
let rndtime = "" //毫秒
let httpResult //global buffer
let host = 'yuekandian.yichengw.cn'
let hostname = 'https://' + host
let yddCookie = ($.isNode() ? process.env.yddCookie : $.getdata('yddCookie')) || '';
let yddCookieArr = []
let userToken = []
let userDevice = []
let userAgent = []
let userCookie = []
let yddSkipWithdraw = ($.isNode() ? process.env.yddSkipWithdraw : $.getdata('yddSkipWithdraw')) || '0';
let skipWithdraw = []
let userIdx = 0
let taskIdx = 0
let coinList = []
let signFlag = []
let contSignFlag = []
let lotteryTicket = []
let lotteryAdTicket = []
let helpTicket = []
let userTicket = []
let userWaitTime = []
let extraRewardFlag = []
let userInfo = []
let withdrawFlag = []
let adVideoFlag = []
let adVideoTicket = []
let doAliFlag = []
let barrierFlag = []
let doneTaskList = []
let doneTaskTicket = []
let NUM_PER_ROUND = 2
let LOTTERY_TYPE = 1
let AD_TICKET_TYPE = 5
let AD_VIDEO_TYPE = 10
let HELP_TYPE = 13
let COIN_TYPE = 14
///////////////////////////////////////////////////////////////////
!(async () => {
if(typeof $request !== "undefined")
{
await GetRewrite()
}
else
{
if(!(await checkEnv())) {
return
}
await initAccountInfo()
await RunMultiUser()
}
})()
.catch((e) => $.logErr(e))
.finally(() => $.done())
//通知
async function showmsg() {
notifyBody = jsname + "运行通知\n\n" + notifyStr
if (notifyFlag != 1) {
console.log(notifyBody);
}
if (notifyFlag == 1) {
$.msg(notifyBody);
//if ($.isNode()){await notify.sendNotify($.name, notifyBody );}
}
}
async function GetRewrite() {
if($request.url.indexOf('/api/v1/member/profile') > -1) {
let headers = $request.headers
let auth = headers.Authorization
if(!auth) return
auth = auth.replace(/Bearer /g,'')
let device = headers['device']
if(!device) return
let ua = headers['User-Agent']
if(!ua) return
let ck = auth + '#' + device + '#' + ua
if(yddCookie) {
if(yddCookie.indexOf(ck) == -1) {
yddCookie = yddCookie + '@' + ck
$.setdata(yddCookie, 'yddCookie');
ckList = yddCookie.split('@')
$.msg(jsname+` 获取第${ckList.length}个yddCookie成功: ${yddCookie}`)
}
} else {
$.setdata(ck, 'yddCookie');
$.msg(jsname+` 获取第1个yddCookie成功: ${ck}`)
}
}
}
async function checkEnv() {
if(yddCookie) {
yddCookie = yddCookie.replace(/Bearer/g,'')
if(yddCookie.indexOf('@') > -1) {
let yddCookies = yddCookie.split('@')
for(let i=0; i<yddCookies.length; i++) {
yddCookieArr.push(yddCookies[i])
}
} else {
yddCookieArr.push(yddCookie)
}
} else {
console.log('未找到yddCookie')
return false
}
if(yddCookieArr.length == 0) {
console.log('未找到有效的yddCookie')
return false
}
for(let items of yddCookieArr) {
let userItem = items.split('#')
userToken.push(userItem[0])
userDevice.push(userItem[1])
userAgent.push(userItem[2])
}
if(yddSkipWithdraw) {
if(yddSkipWithdraw.indexOf(',') > -1) {
skipWithdraw = yddSkipWithdraw.split(',')
} else {
skipWithdraw.push(yddSkipWithdraw)
}
}
console.log(`共找到${yddCookieArr.length}个用户`)
return true
}
async function initAccountInfo() {
for(userIdx=0; userIdx<yddCookieArr.length; userIdx++) {
coinList.push([])
signFlag.push(0)
contSignFlag.push(0)
lotteryTicket.push('')
lotteryAdTicket.push('')
helpTicket.push('')
userTicket.push('')
userWaitTime.push(0)
extraRewardFlag.push(0)
userInfo.push({})
withdrawFlag.push(0)
adVideoFlag.push(0)
adVideoTicket.push('')
doAliFlag.push(0)
barrierFlag.push(0)
doneTaskList.push([])
doneTaskTicket.push([])
}
}
async function RunMultiUser() {
let maxCoinNum = 0
let maxWaitTime = 0
let needSign = 0
let needContSign = 0
let needLottery = 0
let needHelpVideo = 0
let haveTicket = 0
let needAdVideo = 0
let needAliFlag = 0
let needBarrier = 0
let maxDoneTask = 0
//============= 首页气泡红包 =============
console.log('\n查询首页气泡红包...')
for(userIdx=0; userIdx<yddCookieArr.length; userIdx++) {
await QueryCoinInfo()
maxCoinNum = getMax(maxCoinNum,coinList[userIdx].length)
}
await $.wait(100)
if(maxCoinNum > 0) {
console.log('\n开始领取首页气泡红包...')
for(let i=0; i<maxCoinNum; i++) {
for(userIdx=0; userIdx<yddCookieArr.length; userIdx++) {
if(i < coinList[userIdx].length) await GetCoin(coinList[userIdx][i].id)
}
await $.wait(100)
for(userIdx=0; userIdx<yddCookieArr.length; userIdx++) {
if(i < coinList[userIdx].length && coinList[userIdx][i].ad == 1) await WatchAd(COIN_TYPE)
}
await $.wait(100)
for(userIdx=0; userIdx<yddCookieArr.length; userIdx++) {
if(i < coinList[userIdx].length && coinList[userIdx][i].ad == 1) await LogAd(COIN_TYPE)
}
await $.wait(100)
}
}
//============= 签到 =============
console.log('\n查询签到状态...')
for(userIdx=0; userIdx<yddCookieArr.length; userIdx++) {
await QuerySignInfo()
if(signFlag[userIdx]==1) needSign=1
if(contSignFlag[userIdx]==1) needContSign=1
}
await $.wait(100)
if(needSign > 0) {
console.log('\n开始签到...')
for(userIdx=0; userIdx<yddCookieArr.length; userIdx++) {
if(signFlag[userIdx]==1) await DoSign()
}
await $.wait(100)
}
if(needContSign > 0) {
console.log('\n开始领取连续签到奖励...')
for(userIdx=0; userIdx<yddCookieArr.length; userIdx++) {
if(needContSign[userIdx]==1) await RewardContinuesSign()
}
await $.wait(100)
}
//============= 抽奖 =============
console.log('\n查询抽奖状态...')
for(userIdx=0; userIdx<yddCookieArr.length; userIdx++) {
await QueryLotteryInfo()
if(lotteryTicket[userIdx]) needLottery=1
}
await $.wait(100)
if(needLottery > 0) {
console.log('\n开始抽奖...')
for(userIdx=0; userIdx<yddCookieArr.length; userIdx++) {
if(lotteryTicket[userIdx]) await DoLottery(lotteryTicket[userIdx])
}
await $.wait(100)
for(userIdx=0; userIdx<yddCookieArr.length; userIdx++) {
if(lotteryAdTicket[userIdx]) await WatchAd(LOTTERY_TYPE)
}
await $.wait(100)
for(userIdx=0; userIdx<yddCookieArr.length; userIdx++) {
if(lotteryAdTicket[userIdx]) await LogAd(AD_TICKET_TYPE,lotteryTicket[userIdx])
}
await $.wait(100)
}
//============= 闯关换手机 =============
console.log('\n查询闯关状态...')
for(userIdx=0; userIdx<yddCookieArr.length; userIdx++) {
await QueryBarrierInfo()
if(barrierFlag[userIdx]>0) needBarrier=1
}
await $.wait(100)
if(needBarrier > 0) {
for(userIdx=0; userIdx<yddCookieArr.length; userIdx++) {
if(barrierFlag[userIdx]) await DoBarrier(barrierFlag[userIdx])
}
await $.wait(100)
}
//============= 任务状态 =============
console.log('\n查询任务状态...')
for(userIdx=0; userIdx<yddCookieArr.length; userIdx++) {
await QueryTaskList()
if(adVideoFlag[userIdx]) needAdVideo=1
if(doAliFlag[userIdx]) needAliFlag=1
maxDoneTask = getMax(maxDoneTask,doneTaskList[userIdx].length)
}
await $.wait(100)
//============= 领取任务奖励 =============
if(maxDoneTask > 0) {
console.log('\n开始领取任务奖励...')
for(taskIdx=0; taskIdx<maxDoneTask; taskIdx++) {
for(userIdx=0; userIdx<yddCookieArr.length; userIdx++) {
if(taskIdx<doneTaskList[userIdx].length) await doneTaskReward(doneTaskList[userIdx][taskIdx])
}
await $.wait(100)
}
for(taskIdx=0; taskIdx<maxDoneTask; taskIdx++) {
for(userIdx=0; userIdx<yddCookieArr.length; userIdx++) {
if(doneTaskTicket[userIdx][taskIdx]) await WatchAd(LOTTERY_TYPE)
}
await $.wait(100)
}
for(taskIdx=0; taskIdx<maxDoneTask; taskIdx++) {
for(userIdx=0; userIdx<yddCookieArr.length; userIdx++) {
if(doneTaskTicket[userIdx][taskIdx]) await LogAd(AD_TICKET_TYPE,doneTaskTicket[userIdx][taskIdx])
}
await $.wait(100)
}
}
//============= 跳转支付宝任务 =============
if(needAliFlag > 0) {
console.log('\n开始做跳转支付宝任务...')
for(userIdx=0; userIdx<yddCookieArr.length; userIdx++) {
if(doAliFlag[userIdx]==1) await DoAliTask()
}
await $.wait(100)
}
//============= 看广告任务 =============
if(needAdVideo > 0) {
console.log('\n开始看广告...')
for(userIdx=0; userIdx<yddCookieArr.length; userIdx++) {
if(adVideoFlag[userIdx]==1) await DoAdVideo()
}
await $.wait(100)
for(userIdx=0; userIdx<yddCookieArr.length; userIdx++) {
if(adVideoTicket[userIdx]) await WatchAd(AD_VIDEO_TYPE)
}
await $.wait(100)
for(userIdx=0; userIdx<yddCookieArr.length; userIdx++) {
if(adVideoTicket[userIdx]) await LogAd(AD_VIDEO_TYPE)
}
await $.wait(100)
for(userIdx=0; userIdx<yddCookieArr.length; userIdx++) {
if(adVideoTicket[userIdx]) await LogAd(AD_TICKET_TYPE,adVideoTicket[userIdx])
}
await $.wait(100)
}
//============= 看小视频 =============
console.log(`\n准备刷小视频${NUM_PER_ROUND}次...`)
haveTicket = 0
maxWaitTime = 0
for(userIdx=0; userIdx<yddCookieArr.length; userIdx++) {
await GetTicket('video?short=1&')
if(userTicket[userIdx]) {
haveTicket=1
maxWaitTime = getMax(maxWaitTime,userWaitTime[userIdx])
}
}
if(haveTicket > 0) {
for(userIdx=0; userIdx<yddCookieArr.length; userIdx++) {
await TimeRecord('short/video',false)
}
await $.wait(100)
for(let i=0; i<NUM_PER_ROUND && haveTicket > 0; i++) {
haveTicket = 0
console.log(`--- 开始刷第${i+1}轮 ---`)
let waitTime = Math.floor(Math.random()*1000) + maxWaitTime*1000
console.log(`随机等待${waitTime/1000}秒...`)
await $.wait(waitTime)
for(userIdx=0; userIdx<yddCookieArr.length; userIdx++) {
if(userTicket[userIdx]) await Reward('video?',userTicket[userIdx],'short=1&')
if(userTicket[userIdx]) haveTicket=1
}
await $.wait(100)
for(userIdx=0; userIdx<yddCookieArr.length; userIdx++) {
if(extraRewardFlag[userIdx]) await RewardOpen('video','short=1&')
}
await $.wait(100)
}
for(userIdx=0; userIdx<yddCookieArr.length; userIdx++) {
await TimeRecord('short/video',true)
}
await $.wait(100)
}
//============= 看资讯 =============
console.log(`\n准备刷资讯${NUM_PER_ROUND}次...`)
haveTicket = 0
maxWaitTime = 0
for(userIdx=0; userIdx<yddCookieArr.length; userIdx++) {
await GetTicket('news/detail?')
if(userTicket[userIdx]) {
haveTicket=1
maxWaitTime = getMax(maxWaitTime,userWaitTime[userIdx])
}
}
if(haveTicket > 0) {
for(userIdx=0; userIdx<yddCookieArr.length; userIdx++) {
await TimeRecord('news',false)
}
await $.wait(100)
for(let i=0; i<NUM_PER_ROUND && haveTicket > 0; i++) {
haveTicket = 0
console.log(`--- 开始刷第${i+1}轮 ---`)
let waitTime = Math.floor(Math.random()*1000) + maxWaitTime*1000
console.log(`随机等待${waitTime/1000}秒...`)
await $.wait(waitTime)
for(userIdx=0; userIdx<yddCookieArr.length; userIdx++) {
if(userTicket[userIdx]) await Reward('news?',userTicket[userIdx])
if(userTicket[userIdx]) haveTicket=1
}
await $.wait(100)
for(userIdx=0; userIdx<yddCookieArr.length; userIdx++) {
if(extraRewardFlag[userIdx]) await RewardOpen('news')
}
await $.wait(100)
}
for(userIdx=0; userIdx<yddCookieArr.length; userIdx++) {
await TimeRecord('news',true)
}
await $.wait(100)
}
//============= 账户信息 =============
console.log('\n查询账户信息...')
for(userIdx=0; userIdx<yddCookieArr.length; userIdx++) {
await QueryUserInfo()
}
//============= 提现 =============
console.log('\n查询提现信息...')
for(userIdx=0; userIdx<yddCookieArr.length; userIdx++) {
await QueryWithdrawList()
}
}
//查询签到状态
async function QuerySignInfo() {
let caller = printCaller()
let url = `${hostname}/api/v1/reward/sign?`
let urlObject = populateGetUrl(url)
await httpGet(urlObject,caller)
let result = httpResult;
if(!result) return
if(result.code == 0) {
for(let items of result.result.items) {
if(items.days=='今天') {
if(items.status==false) {
signFlag[userIdx] = 1
console.log(`用户${userIdx+1}今天未完成签到`)
} else {
console.log(`用户${userIdx+1}今天已签到`)
}
}
}
for(let items of result.result.ext_items) {
if(result.result.days >= items.days) {
console.log(`用户${userIdx+1}可领取${items.desc}奖励`)
contSignFlag[userIdx] = 1
}
}
} else {
console.log(`用户${userIdx+1}查询签到状态失败:${result.message}`)
}
}
//签到
async function DoSign() {
let caller = printCaller()
let url = `${hostname}/api/v1/reward/sign?`
let urlObject = populatePostUrl(url)
await httpPost(urlObject,caller)
let result = httpResult;
if(!result) return
if(result.code == 0) {
console.log(`用户${userIdx+1}签到获得:${result.result.coin}金币`)
} else {
console.log(`用户${userIdx+1}签到失败:${result.message}`)
}
}
//连续签到奖励
async function RewardContinuesSign() {
let caller = printCaller()
let url = `${hostname}/api/v1/reward/sign/red_envelope?`
let urlObject = populatePostUrl(url)
await httpPost(urlObject,caller)
let result = httpResult;
if(!result) return
if(result.code == 0) {
console.log(`用户${userIdx+1}获得连续签到奖励:${result.result.amount}元`)
} else {
console.log(`用户${userIdx+1}获得连续签到奖励失败:${result.message}`)
}
}
//查询首页金币气泡
async function QueryCoinInfo() {
let caller = printCaller()
let url = `${hostname}/api/v1/reward/coin?`
let urlObject = populateGetUrl(url)
await httpGet(urlObject,caller)
let result = httpResult;
if(!result) return
if(result.code == 0) {
for(let items of result.result.coins) {
if(items.num > 0) {
coinList[userIdx].push(items)
}
}
console.log(`用户${userIdx+1}有${coinList[userIdx].length}个可以领取的首页气泡`)
} else {
console.log(`用户${userIdx+1}查询首页气泡信息失败:${result.message}`)
}
}
//领取首页气泡
async function GetCoin(id) {
let caller = printCaller()
let url = `${hostname}/api/v1/reward/coin?`
let body = `id=${id}&`
let urlObject = populatePostUrl(url,body)
await httpPost(urlObject,caller)
let result = httpResult;
if(!result) return
if(result.code == 0) {
console.log(`用户${userIdx+1}领取首页气泡获得:${result.result.coin}金币`)
} else {
console.log(`用户${userIdx+1}领取首页气泡失败:${result.message}`)
}
}
//查询抽奖状态
async function QueryLotteryInfo() {
let caller = printCaller()
let url = `${hostname}/api/v1/reward/lottery/index?`
let urlObject = populateGetUrl(url)
await httpGet(urlObject,caller)
let result = httpResult;
if(!result) return
if(result.code == 0) {
console.log(`用户${userIdx+1}今天剩余抽奖次数:${result.result.lottery_count}`)
if(result.result.lottery_count>0) {
lotteryTicket[userIdx] = result.result.ticket
}
} else {
console.log(`用户${userIdx+1}查询抽奖状态失败:${result.message}`)
}
}
//抽奖
async function DoLottery(ticket) {
let caller = printCaller()
let url = `${hostname}/api/v1/reward/lottery/index?`
let body = `ticket=${ticket}&`
let urlObject = populatePostUrl(url,body)
await httpPost(urlObject,caller)
let result = httpResult;
if(!result) return
if(result.code == 0) {
if(result.result.type==2) {
lotteryAdTicket[userIdx] = result.result.ticket
console.log(`用户${userIdx+1}抽奖获得:${result.result.num}金币`)
} else if (result.result.type==1) {
console.log(`用户${userIdx+1}抽奖获得:${result.result.num}手机碎片`)
} else {
console.log(result)
}
} else {
console.log(`用户${userIdx+1}抽奖失败:${result.message}`)
}
}
//助力领现金-看视频
async function HelpClick() {
let caller = printCaller()
let url = `${hostname}/api/v1/reward/help/click?`
let urlObject = populateGetUrl(url)
await httpGet(urlObject,caller)
let result = httpResult;
if(!result) return
if(result.code == 0) {
if(result.result && result.result.ticket) {
helpTicket[userIdx] = result.result.ticket
console.log(`用户${userIdx+1}看助力领现金视频将获得${result.result.coin/10000}元余额`)
} else {
console.log(`用户${userIdx+1}看助力领现金视频失败:${result.message}`)
}
} else {
console.log(`用户${userIdx+1}看助力领现金视频失败:${result.message}`)
}
}
//助力领现金信息
async function HelpInfo() {
let caller = printCaller()
let url = `${hostname}/api/v1/reward/help/index?`
let urlObject = populateGetUrl(url)
await httpGet(urlObject,caller)
let result = httpResult;
if(!result) return
if(result.code == 0) {
console.log(`用户${userIdx+1}助力领现金金额:${result.result.jinbi}元,还差${result.result.diff_jinbi}元可以提现`)
} else {
console.log(`用户${userIdx+1}看助力领现金视频失败:${result.message}`)
}
}
//开始广告
async function WatchAd(type) {
let caller = printCaller()
let url = `${hostname}/api/v1/ad/topon/placement/id?type=${type}&`
let urlObject = populateGetUrl(url)
await httpGet(urlObject,caller)
let result = httpResult;
if(!result) return
if(result.code == 0) {
console.log(`用户${userIdx+1}开始看广告`)
} else {
console.log(`用户${userIdx+1}看广告失败:${result.message}`)
}
}
//完成广告
async function LogAd(type,ticket='') {
let caller = printCaller()
let ticketStr = ''
if(ticket) ticketStr = `ticket=${ticket}&`
let url = `${hostname}/api/v1/ad/log?${ticketStr}type=${type}&`
let urlObject = populateGetUrl(url)
await httpGet(urlObject,caller)
let result = httpResult;
if(!result) return
if(result.code == 0) {
console.log(`用户${userIdx+1}完成看广告`)
} else {
console.log(`用户${userIdx+1}完成看广告失败:${result.message}`)
}
}
//获取ticket
async function GetTicket(suburl) {
userTicket[userIdx] = ''
userWaitTime[userIdx] = 0
let caller = printCaller()
let url = `${hostname}/api/v1/reward/${suburl}`
let urlObject = populateGetUrl(url)
await httpGet(urlObject,caller)
let result = httpResult;
if(!result) return
if(result.code == 0) {
if(result.result.coin_status==1) {
if(result.result.ticket) {
userTicket[userIdx] = result.result.ticket
userWaitTime[userIdx] = result.result.time
console.log(`用户${userIdx+1}获取到ticket`)
} else {
console.log(`用户${userIdx+1}获取ticket失败:${result.message}`)
}
} else {
console.log(`用户${userIdx+1}已无法获得更多金币`)
}
} else {
console.log(`用户${userIdx+1}获取ticket失败:${result.message}`)
}
}
//记录时间
async function TimeRecord(suburl,isEnd=false) {
let caller = printCaller()
let endStr = ''
let desc = '开始'
if(isEnd) {
endStr = 'end=1&'
desc = '结束'
}
let url = `${hostname}/api/v1/reward/${suburl}/interval?${endStr}`
let urlObject = populateGetUrl(url)
await httpGet(urlObject,caller)
let result = httpResult;
if(!result) return
if(result.code == 0) {
console.log(`用户${userIdx+1}${desc}记录时长`)
} else {
console.log(`用户${userIdx+1}${desc}记录时长失败:${result.message}`)
}
}
//获得奖励
async function Reward(suburl,ticket,subbody='') {
extraRewardFlag[userIdx] = 0
userTicket[userIdx] = ''
userWaitTime[userIdx] = 0
let caller = printCaller()
let url = `${hostname}/api/v1/reward/${suburl}`
let body = `ticket=${ticket}&${subbody}`
let urlObject = populatePostUrl(url,body)
await httpPost(urlObject,caller)
let result = httpResult;
if(!result) return
if(result.code == 0) {
if(result.result.count >= result.result.target && result.result.ren_status == 1) extraRewardFlag[userIdx]=1
if(result.result.ticket) {
userTicket[userIdx] = result.result.ticket
userWaitTime[userIdx] = result.result.time
console.log(`用户${userIdx+1}获取到下一个ticket`)
} else {
console.log(`用户${userIdx+1}获取下一个ticket失败:${result.message}`)
}
console.log(`用户${userIdx+1}获得:${result.result.reward}金币,额外奖励次数${result.result.target},目前已刷${result.result.count}次`)
} else {
console.log(`用户${userIdx+1}获得奖励失败:${result.message}`)
}
}
//额外次数奖励
async function RewardOpen(suburl,body='') {
let caller = printCaller()
let url = `${hostname}/api/v1/reward/${suburl}/open?`
let urlObject = populatePostUrl(url,body)
await httpPost(urlObject,caller)
let result = httpResult;
if(!result) return
if(result.code == 0) {
console.log(`用户${userIdx+1}获得额外奖励:${result.result.reward}金币`)
} else {
console.log(`用户${userIdx+1}获得额外奖励失败:${result.message}`)
}
}
//账号信息
async function QueryUserInfo() {
let caller = printCaller()
let url = `${hostname}/api/v1/member/profile?debug=0&`
let urlObject = populateGetUrl(url)
await httpGet(urlObject,caller)
let result = httpResult;
if(!result) return
if(result.code == 0) {
console.log(`\n==== 用户${userIdx+1}: ${result.result.nickname} ====`)
console.log(`今日收益: ${result.result.today_point}`)
console.log(`提现券 : ${result.result.ticket}`)
console.log(`手机碎片: ${result.result.fragment}`)
console.log(`金币余额: ${result.result.point}`)
console.log(`历史收益: ${result.result.total_point}`)
userInfo[userIdx] = result.result
} else {
console.log(`用户${userIdx+1}查询账号信息失败:${result.message}`)
}
}
//提现列表
async function QueryWithdrawList() {
let caller = printCaller()
let url = `${hostname}/api/v1/cash/exchange?`
let urlObject = populateGetUrl(url)
await httpGet(urlObject,caller)
let result = httpResult;
if(!result) return
if(result.code == 0) {
let sortList = result.result.items.sort(function(a,b){return b["jine"]-a["jine"]});
for(let item of sortList) {
let skipFlag = 0
if(skipWithdraw.length>0) {
for(let skipItem of skipWithdraw) {
if(item.jine == skipItem) {
skipFlag = 1
break
}
}
}
if(skipFlag==1) {
console.log(`用户${userIdx+1}跳过提现${item.jine}元`)
continue
}
if(userInfo[userIdx].point>=item.jinbi && userInfo[userIdx].ticket>=item.cond && item.is_ok==1) {
console.log(`用户${userIdx+1}准备提现${item.jine}元`)
await Withdraw(item.jine)
if(withdrawFlag[userIdx]==1) break;
}
}
} else {
console.log(`用户${userIdx+1}查询提现列表失败:${result.message}`)
}
}
//提现
async function Withdraw(amount) {
let caller = printCaller()
let url = `${hostname}/api/v1/cash/exchange?`
let body = `amount=${amount}&gate=wechat&`
let urlObject = populatePostUrl(url,body)
await httpPost(urlObject,caller)
let result = httpResult;
if(!result) return false
if(result.code == 0) {
withdrawFlag[userIdx] = 1
console.log(`用户${userIdx+1}提现${amount}:${result.result.title}, ${result.result.message}`)
} else {
console.log(`用户${userIdx+1}提现${amount}失败:${result.message}`)
}
return false
}
//获取任务列表状态
async function QueryTaskList() {
let caller = printCaller()
let url = `${hostname}/api/v1/zhuan/index?`
let urlObject = populatePostUrl(url)
await httpPost(urlObject,caller)
let result = httpResult;
if(!result) return
if(result.code == 0) {
for(let item of result.result.items) {
let str = (item.st==0) ? '未完成' : '已完成'
if(item.title.indexOf('观看广告视频') > -1) {
let matchItem = item.title.match(/"red">(\w+)<\/font>\/(\w+)/)
str = (parseInt(matchItem[2]) > parseInt(matchItem[1])) ? '未完成' : '已完成'
if(item.st==0) adVideoFlag[userIdx] = 1
console.log(`用户${userIdx+1}${str}看广告任务,总次数${matchItem[2]}次,已完成${matchItem[1]}次`)
} else if(item.title.indexOf('支付宝红包') > -1) {
if(item.st==0) doAliFlag[userIdx] = 1
console.log(`用户${userIdx+1}${str}跳转支付宝任务`)
} else if(item.title.indexOf('看资讯') > -1) {
let matchItem = item.rate.split('$')
console.log(`用户${userIdx+1}${str}看资讯任务,总次数${matchItem[1]}次,已完成${matchItem[0]}次`)
} else if(item.title.indexOf('刷视频') > -1) {
let matchItem = item.rate.split('$')
console.log(`用户${userIdx+1}${str}刷视频任务,总次数${matchItem[1]}次,已完成${matchItem[0]}次`)
}
if(item.st==1) {
if(item.id != 10 && item.time <= 0) {
doneTaskList[userIdx].push(item.id)
doneTaskTicket[userIdx].push('')
}
}
}
} else {
console.log(`用户${userIdx+1}获取任务列表状态失败:${result.message}`)
}
}
//获取看广告视频任务ticket
async function DoAdVideo() {
let caller = printCaller()
let url = `${hostname}/api/v1/zhuan/video?`
let urlObject = populatePostUrl(url)
await httpPost(urlObject,caller)
let result = httpResult;
if(!result) return
if(result.code == 0) {
if(result.result.ticket) {
adVideoTicket[userIdx] = result.result.ticket
console.log(`用户${userIdx+1}获取看广告视频ticket成功,将获得:${result.result.coin}金币,${result.result.coupon}提现券`)
} else {
console.log(`用户${userIdx+1}获取看广告视频ticket失败`)
}
} else {
console.log(`用户${userIdx+1}获取看广告视频ticket失败:${result.message}`)
}
}
//跳转支付宝
async function DoAliTask() {
let caller = printCaller()
let url = `${hostname}/api/v1/zhuan/aliaaa?`
let urlObject = populateGetUrl(url)
await httpGet(urlObject,caller)
let result = httpResult;
if(!result) return
if(result.code == 0) {
console.log(`用户${userIdx+1}完成跳转支付宝任务`)
} else {
console.log(`用户${userIdx+1}完成跳转支付宝任务失败:${result.message}`)
}
}
//闯关换手机状态
async function QueryBarrierInfo() {
let caller = printCaller()
let url = `${hostname}/api/v1/reward/barrier/index?`
let urlObject = populateGetUrl(url)
await httpGet(urlObject,caller)
let result = httpResult;
if(!result) return
if(result.code == 0) {
console.log(`用户${userIdx+1}今天已闯关${result.result.current_barrier}次`)
if(result.result.current_barrier<7) {
barrierFlag[userIdx] = parseInt(result.result.current_barrier) + 1
}
} else {
console.log(`用户${userIdx+1}获取看广告视频ticket失败:${result.message}`)
}
}
//闯关
async function DoBarrier(num) {
let caller = printCaller()
let url = `${hostname}/api/v1/reward/barrier/index?`
let body = `no=${num}&`
let urlObject = populatePostUrl(url,body)
await httpPost(urlObject,caller)
let result = httpResult;
if(!result) return
if(result.code == 0) {
console.log(`用户${userIdx+1}闯关获得:${result.result.coin}金币,${result.result.fragment}手机碎片`)
} else {
console.log(`用户${userIdx+1}闯关失败:${result.message}`)
}
}
//领任务奖励
async function doneTaskReward(id) {
let caller = printCaller()
let url = `${hostname}/api/v1/zhuan/done?`
let body = `id=${id}&`
let urlObject = populatePostUrl(url,body)
await httpPost(urlObject,caller)
let result = httpResult;
if(!result) return
if(result.code == 0) {
if(result.result.ticket) doneTaskTicket[userIdx][taskIdx] = result.result.ticket
console.log(`用户${userIdx+1}领取任务[id=${id}]奖励获得:${result.result.coin}金币`)
} else {
console.log(`用户${userIdx+1}领取任务[id=${id}]奖励失败:${result.message}`)
}
}
////////////////////////////////////////////////////////////////////
function populatePostUrl(url,reqBody=''){
let urlObject = {
url: url,
headers: {
'Host' : 'yuekandian.yichengw.cn',
'version' : '8',
'Authorization' : 'Bearer ' + userToken[userIdx],
'Accept-Language' : 'zh-CN,zh-Hans;q=0.9',
'Accept-Encoding' : 'gzip, deflate, br',
'platform' : '2',
'Accept' : '*/*',
'User-Agent' : userAgent[userIdx],
'Connection' : 'keep-alive',
'device' : userDevice[userIdx],
'store' : '100',
},
body: reqBody
}
if(userAgent[userIdx].indexOf('CBD') > -1) {
urlObject.headers['version'] = '2'
urlObject.headers['app'] = '3'
} else if(userAgent[userIdx].indexOf('KDB') > -1) {
urlObject.headers['version'] = '1'
urlObject.headers['app'] = '5'
}
return urlObject;