forked from fridayon/JKD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jkd.js
1532 lines (1489 loc) · 56.4 KB
/
jkd.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
/*
聚看点,所有任务+阅读
欢迎填写邀请码:24230233
点我的获取Cookie
=============环境变量=============
JKD_COOKIE cookies,可选择用&、@、换行隔开
JKD_USER_AGENT 用户ua,默认为ios
JKD_WITHDRAW 提现金额
JKD_FAKE_IOS 将安卓cookie伪装成iOS 默认伪装,填写任意值
JKD_NOTIFY 是否开启通知,开启则22点通知一次
================Qx==============
[task_local]
0,30 7-22/1 * * * https://raw.githubusercontent.com/shylocks/Loon/main/jkd.js, tag=聚看点
[rewrite_local]
https:\/\/www\.xiaodouzhuan\.cn\/jkd\/newMobileMenu\/infoMe\.action url script-request-body https://raw.githubusercontent.com/shylocks/Loon/main/jkd.js
================Loon==============
[Script]
http-request https:\/\/www\.xiaodouzhuan\.cn\/jkd\/newMobileMenu\/infoMe\.action script-path=https://raw.githubusercontent.com/shylocks/Loon/main/jkd.js, requires-body=true, timeout=100, tag=聚看点
cron "0,30 7-22/1 * * *" script-path=https://raw.githubusercontent.com/shylocks/Loon/main/jkd.js
===============Surge=================
[Script]
聚看点 = type=http-request,pattern=https:\/\/www\.xiaodouzhuan\.cn\/jkd\/newMobileMenu\/infoMe\.action ,script-path=https://raw.githubusercontent.com/shylocks/Loon/main/jkd.js
聚看点 = type=cron,cronexp="0,30 7-22/1 * * *",wake-system=1,timeout=900,script-path=https://raw.githubusercontent.com/shylocks/Loon/main/jkd.js
===============MITM=================
[MITM]
hostname = www.xiaodouzhuan.cn
*/
const API_HOST = 'https://www.xiaodouzhuan.cn'
let UA = 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_2_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148'
const DATE = `${new Date().getUTCFullYear()}${(new Date().getUTCMonth() + 1).toString().padStart(2, "0")}${new Date().getUTCDate().toString().padStart(2, "0")}`
let liveBody = null, fakeIOS = true
const $ = new Env("聚看点")
let sum = 0
let cookiesArr = [
// '', // xz_jkd_appkey=xxx; JSESSIONID=xxx; UM_distinctid=xxx; (账号1ck)
// '', // xz_jkd_appkey=xxx; JSESSIONID=xxx; UM_distinctid=xxx; (账号2ck)
], cookie = '', message;
let notify = !$.isNode() ? $.getdata("JKD_MSG") : !!process.env.JKD_NOTIFY
const ntf = $.isNode() ? require('./sendNotify') : '';
async function getCookie() {
if ($request && $request.method !== `OPTIONS`) {
const bodyVal = $request.body
let cks = $.getdata('CookiesJKD2') || "[]"
cks = jsonParse(cks);
const Cookieval = $request.headers['Cookie']
$.log(`Cookie:${Cookieval}`)
$.log(`bodyVal:${bodyVal}`)
if (Cookieval) {
let os = []
for (let i = 0; i < cks.length; ++i) {
cookie = cks[i]
await getOpenId()
os.push($.openId)
}
cookie = Cookieval
await getOpenId()
if ($.openId && !os.includes($.openId)) {
cks.push(Cookieval)
$.setdata(JSON.stringify(cks), "CookiesJKD2")
$.msg($.name, `获取Cookie ${$.openId} 成功`)
} else {
if (!$.openId) {
$.msg($.name, `无法获取openId,请检查是否绑定微信`)
} else {
$.msg($.name, `openId ${$.openId} 已存在`)
}
// $.msg($.name, `${$.userName}已存在,请注释脚本`)
}
}
}
}
if (typeof $request !== 'undefined') {
getCookie().then(r => {
$.done()
}).finally(() => {
$.done()
resolve()
})
} else {
!(async () => {
if ($.isNode()) {
let JKCookie = []
if (process.env.JKD_COOKIE && process.env.JKD_COOKIE.indexOf('@') > -1) {
JKCookie = process.env.JKD_COOKIE.split('@');
console.log(`您的JKD_COOKIE选择的是用@隔开,共计 ${JKCookie.length} 个Cookie\n`)
} else if (process.env.JKD_COOKIE && process.env.JKD_COOKIE.indexOf('&') > -1) {
JKCookie = process.env.JKD_COOKIE.split('&');
console.log(`您的JKD_COOKIE选择的是用&隔开,共计 ${JKCookie.length} 个Cookie\n`)
} else if (process.env.JKD_COOKIE && process.env.JKD_COOKIE.indexOf('\n') > -1) {
JKCookie = process.env.JKD_COOKIE.split('\n');
console.log(`您的JKD_COOKIE选择的是用换行符隔开,共计 ${JKCookie.length} 个Cookie\n`)
} else if (process.env.JKD_COOKIE) {
JKCookie = process.env.JKD_COOKIE.split()
}
if (process.env.JKD_WITHDRAW) {
sum = process.env.JKD_WITHDRAW
}
Object.keys(JKCookie).forEach((item) => {
if (JKCookie[item]) {
cookiesArr.push(JKCookie[item])
}
})
if (process.env.TENCENTCLOUD_RUNENV) {
$.scf = true
}
if (process.env.JKD_DEBUG && process.env.JKD_DEBUG === 'false') console.log = () => {
};
} else {
let cookiesData = $.getdata('CookiesJKD2') || "[]";
sum = $.getdata("JKD_WITHDRAW") || 0;
cookiesData = jsonParse(cookiesData);
cookiesArr = cookiesData.length > 0 ? cookiesData : cookiesArr;
cookiesArr.reverse();
cookiesArr = cookiesArr.filter(item => item !== "" && item !== null && item !== undefined);
}
if (!cookiesArr[0]) {
$.msg($.name, '【提示】请先获取聚看点账号一cookie');
return;
}
await requireConfig()
for (let i = 0; i < cookiesArr.length; i++) {
if (cookiesArr[i]) {
cookie = cookiesArr[i];
if (cookie.match(/UM_distinctid=(\S*);/)) {
$.uuid = cookie.match(/UM_distinctid=(\S*);/)[1]
} else $.uuid = ""
await getOpenId()
$.index = i + 1;
$.message = ''
if (!$.openId) {
console.log(`Cookies${$.index}已失效!`)
break
}
if (liveBody[$.openId]) {
if (!liveBody[$.openId][DATE]) {
liveBody[$.openId][DATE] = {
"livetime": 0,
"articletime": 0,
"videotime": 0,
}
$.log('当日liveBody不存在,新建')
$.isSign = false
} else {
$.log('当日liveBody已存在')
$.isSign = true
}
} else {
liveBody[$.openId] = {}
liveBody[$.openId][DATE] = {
"livetime": 0,
"articletime": 0,
"videotime": 0,
}
$.log('当日liveBody不存在,新建')
$.isSign = false
}
await getUserInfo()
console.log(`\n******开始【聚看点账号${$.index}】${$.userName || $.openId}*********\n`);
console.log(`${$.gold},当前 ${$.current} 元,累计 ${$.sum} 元`)
$.iOS = true
if (cookie.indexOf('iOS') > 0) {
console.log(`${$.userName}的cookie来自iOS客户端`)
fakeIOS = false
UA = 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148'
} else if (cookie.indexOf('android') > 0) {
console.log(`${$.userName}的cookie来自安卓客户端`)
// $.iOS = false
if (!fakeIOS)
UA = 'Dalvik/2.1.0 (Linux; U; Android 10; ONEPLUS A5010 Build/QKQ1.191014.012)'
else {
console.log(`将cookie中的安卓标示替换为iOS`)
cookie = cookie.replace('!android!753', '!iOS!5.6.5')
}
} else {
console.log(`无法获取客户端标示,请检查cookie是否正确`)
}
await jkd()
await showMsg()
}
}
})()
.catch((e) => $.logErr(e))
.finally(async () => {
if (!$.isNode()) {
$.setdata(JSON.stringify(liveBody), "jkdLiveBody")
} else if (!$.scf) {
const fs = require('fs');
try {
await fs.writeFileSync('jkd.json', JSON.stringify(liveBody));
} catch (err) {
console.error(err)
}
}
$.done()
})
}
function requireConfig() {
if (!$.isNode()) {
if ($.getdata("jkdLiveBody") != null) {
console.log('加载本地阅读时长body')
liveBody = JSON.parse($.getdata("jkdLiveBody"))
if (liveBody === null) {
liveBody = {}
}
} else {
console.log('没有阅读时长body,新建')
liveBody = {}
}
} else {
const fs = require('fs');
try {
if (!fs.existsSync('jkd.json')) {
$.log('未找到活跃时间body,新建')
liveBody = {}
} else {
$.log('读取本地活跃时间body')
let raw = fs.readFileSync('jkd.json').toString();
liveBody = JSON.parse(raw) ? JSON.parse(raw) : {}
}
} catch (err) {
liveBody = {}
console.error(err)
}
if (process.env.JKD_FAKE_IOS !== undefined && process.env.JKD_FAKE_IOS !== null && process.env.JKD_FAKE_IOS !== '')
fakeIOS = false
}
}
async function showMsg() {
if (!$.isNode() || notify) {
$.msg(`【账号${$.name}${$.index} ${$.userName}】`, `${$.gold},当前 ${$.current} 元,累计 ${$.sum} 元`, $.message)
} else {
$.log(`【账号${$.name}${$.index} ${$.userName}】\n ${$.gold},当前 ${$.current} 元,累计 ${$.sum} 元\n ${$.message}`)
if (new Date().getUTCHours() === 14 && new Date().getUTCMinutes() < 10 && notify) {
await ntf.sendNotify(`【${$.name}账号${$.index} ${$.userName}】`, `${$.gold},当前 ${$.current} 元,累计 ${$.sum} 元\n`);
}
}
}
async function jkd() {
let st = new Date().getTime()
await call3($.uuid, "OPEN_APP")
if (sum !== 0 && $.current > sum) {
console.log(`触发提现条件,去提现`)
await withDraw()
}
$.profit = 0
await bindTeacher()
if (!$.isSign) await sign() // 签到
$.log(`去领取阶段奖励`)
await getStageState() // 阶段奖励
$.luckyDrawNum = 50
if ($.luckyDrawNum > 0) {
$.log(`去转转盘`)
for (let i = 0; i < 10 && $.luckyDrawNum > 0; ++i) {
await getLuckyLevel()
if ($.luckyDrawNum === 0) break
await luckyDraw()
await luckyProfit()
await $.wait(1000)
}
}
// await getTaskList() // 任务
for (let i = 0; i < $.videoPacketNum && !$.scf; ++i) {
$.log(`去看激励视频`)
await adv(17)
}
await openTimeBox() // 宝箱
await getTaskBoxProfit() // 摇钱树1
await getTaskBoxProfit(2) // 摇钱树2
$.artList = []
// 看视频
let stA = new Date().getTime()
await getArticleList(53)
for (let i = 0; i < $.artList.length; ++i) {
const art = $.artList[i]
if (art['art_id']) {
let artId = art['art_id']
await call2($.uuid)
if ($.videocount === 0) {
$.log(`观看视屏次数已满,跳出`)
break
}
$.log(`去看视频:${artId}`)
await call1($.uuid, artId)
await getVideo(artId, true)
await video(artId)
await call1($.uuid)
await $.wait(31 * 1000)
await videoAccount(artId)
await $.wait(5 * 1000)
}
}
let etA = new Date().getTime()
let addArticleTime = Math.trunc((etA - stA) / 1000)
$.artList = []
// 看文章
let stV = new Date().getTime()
await getArticleList()
for (let i = 0; i < $.artList.length; ++i) {
const art = $.artList[i]
if (art['art_id']) {
await call2($.uuid)
if ($.artcount === 0) {
$.log(`观看文章次数已满,跳出`)
break
}
let artId = art['art_id']
await getArticle(artId)
await call1($.uuid, artId)
await article(artId)
await openArticle(artId)
await $.wait(31 * 1000)
await readAccount(artId)
await $.wait(5 * 1000)
}
}
let etV = new Date().getTime()
let addVideoTime = Math.trunc((etV - stV) / 1000)
await $.wait(1000)
let et = new Date().getTime()
let addLiveTime = Math.trunc((et - st) / 1000)
liveBody[$.openId][DATE]['livetime'] += addLiveTime
liveBody[$.openId][DATE]['articletime'] += addArticleTime
liveBody[$.openId][DATE]['videotime'] += addVideoTime
let body = {
'livetime': (liveBody[$.openId][DATE]['livetime'] * 1000).toString(),
'articletime': (liveBody[$.openId][DATE]['articletime'] * 1000).toString(),
'videotime': (liveBody[$.openId][DATE]['videotime'] * 1000).toString(),
'addlivetime': (addLiveTime * 1000).toString(),
'addarticletime': (addArticleTime * 1000).toString(),
'addvideotime': (addVideoTime * 1000).toString(),
}
$.message += `本次运行增加活跃时间 ${addLiveTime} 秒\n`
await userLive(body)
$.log(`本次运行完成,共计获得 ${$.profit} 金币`)
$.message += `本次运行获得 ${$.profit} 金币\n`
await getUserInfo()
}
function userLive(body) {
// 保活
let postBody = {
...body,
"appid": "xzwl",
"channel": $.iOS ? "iOS" : "android",
"psign": "92dea068b6c271161be05ed358b59932",
"appversioncode": $.version,
"time": new Date().getTime(),
"apptoken": "xzwltoken070704",
"appversion": fakeIOS ? '5.6.5' : $.version.toString().split('').join('.'),
"openid": $.openId,
"os": $.iOS ? "iOS" : "android",
"opdate": `${DATE}`
}
return new Promise(resolve => {
$.post(taskPostUrl("jkd/user/userlive.action",
`jsondata=${escape(JSON.stringify(postBody))}`), async (err, resp, data) => {
try {
if (err) {
$.log(`${JSON.stringify(err)}`)
$.log(`${$.name} API请求失败,请检查网路重试`)
} else {
if (safeGet(data)) {
data = JSON.parse(data);
if (data['ret'] === 'ok') {
console.log('增加阅读时长成功!')
} else {
$.log(`获取任务列表失败,错误信息:${JSON.stringify(data)}`)
}
}
}
} catch (e) {
$.logErr(e, resp)
} finally {
resolve(data);
}
})
})
}
function bindTeacher() {
return new Promise(resolve => {
$.get(taskGetUrl("jkd/weixin20/member/bindTeacher.action", "teacherCode=24224873"), async (err, resp, data) => {
try {
if (err) {
$.log(`${JSON.stringify(err)}`)
$.log(`${$.name} API请求失败,请检查网路重试`)
} else {
// console.log(data)
}
} catch (e) {
$.logErr(e, resp)
} finally {
resolve(data);
}
})
})
}
function getStageState() {
return new Promise(resolve => {
$.post(taskGetUrl("jkd/weixin20/newactivity/readStageReward.action",), async (err, resp, data) => {
try {
if (err) {
$.log(`${JSON.stringify(err)}`)
$.log(`${$.name} API请求失败,请检查网路重试`)
} else {
for (let i = 1; i <= 3; ++i) {
let str = `var readtime${i} = "(.*)";`
switch (parseInt(data.match(str)[1])) {
case 1:
$.log(`第${i}阶段奖励可领取`)
await getStageReward(i)
break
case 2:
$.log(`第${i}阶段奖励已领取过`)
break
default:
$.log(`第${i}阶段未完成`)
break
}
}
//$.isSign = data.match(/var readtime1 = "(.*)";/)[1]
}
} catch (e) {
$.logErr(e, resp)
} finally {
resolve(data);
}
})
})
}
function getTaskList() {
let body = {
"appid": "xzwl",
"channel": $.iOS ? "iOS" : "android",
"psign": "92dea068b6c271161be05ed358b59932",
"appversioncode": $.version,
"time": new Date().getTime(),
"apptoken": "xzwltoken070704",
"appversion": fakeIOS ? '5.6.5' : $.version.toString().split('').join('.'),
"openid": $.openId,
"os": $.iOS ? "iOS" : "android",
"listtype": "wealnews",
"ua": $.isNode() ?
(process.env.JKD_USER_AGENT ? process.env.JKD_USER_AGENT : UA) : ($.getdata('JKDUA')
? $.getdata('JKDUA') : UA),
"pageNo": 0,
"pageSize": 20
}
return new Promise(resolve => {
$.post(taskGetUrl("jkd/mobile/base/welfaretask/indexList.action",
`jsondata=${escape(JSON.stringify(body))}`), async (err, resp, data) => {
try {
if (err) {
$.log(`${JSON.stringify(err)}`)
$.log(`${$.name} API请求失败,请检查网路重试`)
} else {
if (safeGet(data)) {
data = JSON.parse(data);
if (data['ret'] === 'ok') {
const taskList = data.data.data.list
for (let i = 0; i < taskList.length; ++i) {
const task = taskList[i]
if (task['tstatus'] === 1) {
$.log(`去做任务【${task['name']}】`)
await doTask(task['pid'], task['name'], "doTask")
await doTask(task['pid'], task['name'], "getMoney")
await $.wait(15 * 1000)
}
}
} else {
$.log(`获取任务列表失败,错误信息:${JSON.stringify(data)}`)
}
}
}
} catch (e) {
$.logErr(e, resp)
} finally {
resolve(data);
}
})
})
}
function doTask(taskId, taskName, action) {
let body = {
"appid": "xzwl",
//"exporturl": "https:\/\/kyshiman.com\/kkz\/channel?ref=436",
//"pageurl": "https:\/\/new.huanzhuti.com\/news\/26382197?cid=qsbk02",
"slidenum": 1,
"channel": $.iOS ? "iOS" : "android",
"psign": "92dea068b6c271161be05ed358b59932",
"appversioncode": `${$.version}`,
"time": `${new Date().getTime()}`,
"apptoken": "xzwltoken070704",
"appversion": fakeIOS ? '5.6.5' : $.version.toString().split('').join('.'),
"openid": $.openID,
"os": $.iOS ? "iOS" : "android",
"operatepath": "adDetail",
"taskId": taskId,
"billingtype": 2,
"pagetype": "adDetail",
// "name": taskName,
"taskExecuteId": 0
}
$.log(`jsondata=${escape(JSON.stringify(body))}`)
return new Promise(resolve => {
$.post(taskPostUrl(`jkd/mobile/base/welfaretask/${action}.action`,
`jsondata=${escape(JSON.stringify(body))}`), async (err, resp, data) => {
try {
if (err) {
$.log(`${JSON.stringify(err)}`)
//$.log(resp)
$.log(`${$.name} API请求失败,请检查网路重试`)
} else {
if (safeGet(data)) {
data = JSON.parse(data);
if (data['ret'] === 'ok') {
const taskList = data.data.data.list
for (let i = 0; i < taskList.length; ++i) {
const task = taskList[i]
if (task['tstatus'] === 1) {
await doTask()
}
}
} else {
$.log(`获取任务列表失败,错误信息:${JSON.stringify(data)}`)
}
}
}
} catch (e) {
$.logErr(e, resp)
} finally {
resolve(data);
}
})
})
}
function getOpenId() {
return new Promise(resolve => {
$.post(taskGetUrl("jkd/task/userSign.action", `channel=${$.iOS ? "iOS" : "android"}`), async (err, resp, data) => {
try {
if (err) {
$.log(`${JSON.stringify(err)}`)
$.log(`${$.name} API请求失败,请检查网路重试`)
} else {
$.openId = data.match(/var openid = "(\S*)"/)[1]
$.version = data.match(/var myversions = parseInt\("(.*)"\)/)[1]
if ($.openId) {
$.log(`获取openId成功`)
}
// $.isSign = data.match(/var issign = parseInt\("(.*)"\)/)[1]
$.videoPacketNum = data.match(/var videoPacketNum = (\S*);/)[1]
$.newsTaskNum = data.match(/var newsTaskNum = (\S*);/)[1]
$.luckyDrawNum = (data.match(/var luckDrawTaskNum = (\S*);/)[1])
}
} catch (e) {
$.logErr(e, resp)
} finally {
resolve(data);
}
})
})
}
function getUserInfo() {
let body = {
"openid": $.openId,
"channel": $.iOS ? "iOS" : "android",
"os": $.iOS ? "iOS" : "android",
"appversioncode": $.version,
"time": new Date().getTime().toString(),
"psign": "92dea068b6c271161be05ed358b59932",
"apptoken": "xzwltoken070704",
"appid": "xzwl",
"appversion": fakeIOS ? '5.6.5' : $.version.toString().split('').join('.'),
}
return new Promise(resolve => {
$.post(taskPostUrl("jkd/newMobileMenu/infoMe.action",
`jsondata=${escape(JSON.stringify(body))}`), async (err, resp, data) => {
try {
if (err) {
$.log(`${JSON.stringify(err)}`)
$.log(`${$.name} API请求失败,请检查网路重试`)
} else {
if (safeGet(data)) {
data = JSON.parse(data);
if (data['ret'] === 'ok') {
$.userName = data.userinfo.username
$.sum = data.userinfo.infoMeSumCashItem.value
$.gold = data.userinfo.infoMeGoldItem.title + ": " + data.userinfo.infoMeGoldItem.value
$.current = data.userinfo.infoMeCurCashItem.value
} else {
$.log(`个人信息获取失败,错误信息:${JSON.stringify(data)}`)
}
}
}
} catch (e) {
$.logErr(e, resp)
} finally {
resolve(data);
}
})
})
}
function sign() {
let body = `openID=${$.openId}&accountType=0`
return new Promise(resolve => {
$.get(taskGetUrl("jkd/task/sign.action", body), async (err, resp, data) => {
try {
if (err) {
$.log(`${JSON.stringify(err)}`)
$.log(`${$.name} API请求失败,请检查网路重试`)
} else {
if (safeGet(data)) {
data = JSON.parse(data);
if (data['ret'] === 'ok') {
$.profit += data.datas.signAmt
$.log(`签到成功,获得 ${data.datas.signAmt} 金币,已签到 ${data.datas.signDays} 天,下次签到金币:${data.datas.nextSignAmt}`)
$.message += `签到成功,获得 ${data.datas.signAmt} 金币,已签到 ${data.datas.signDays} 天,下次签到金币:${data.datas.nextSignAmt}\n`
$.log(`去做签到分享任务`)
await signShare(data.datas.position)
} else {
$.log(`签到失败,错误信息:${JSON.stringify(data)}`)
}
}
}
} catch (e) {
$.logErr(e, resp)
} finally {
resolve(data);
}
})
})
}
function getTaskBoxProfit(boxType = 1) {
let body = `box_type=${boxType}`
return new Promise(resolve => {
$.post(taskPostUrl("jkd/task/getTaskBoxProfit.action", body), async (err, resp, data) => {
try {
if (err) {
$.log(`${JSON.stringify(err)}`)
$.log(`${$.name} API请求失败,请检查网路重试`)
} else {
if (safeGet(data)) {
data = JSON.parse(data);
if (data['ret'] === 'ok') {
$.log(`摇钱树开启成功,获得 ${data.profit} 金币`)
$.profit += data.profit
if (data.advertPopup && data.advertPopup.advert && !$.scf) {
$.log(`去做额外翻倍任务`)
await adv(data.advertPopup.position)
}
} else if (data['ret'] === 'fail') {
$.log(`摇钱树开启失败,错误信息:${data.rtn_msg}`)
} else {
$.log(`未知错误:${JSON.stringify(data)}`)
}
}
}
} catch (e) {
$.logErr(e, resp)
} finally {
resolve(data);
}
})
})
}
function signShare(position) {
let body = {
"openid": $.openId,
"channel": $.iOS ? "iOS" : "android",
"os": $.iOS ? "iOS" : "android",
"appversioncode": `${$.version}`,
"time": `${new Date().getTime()}`,
"psign": "92dea068b6c271161be05ed358b59932",
"position": position,
"apptoken": "xzwltoken070704",
"appid": "xzwl",
"appversion": fakeIOS ? '5.6.5' : $.version.toString().split('').join('.'),
}
return new Promise(resolve => {
$.post(taskPostUrl("jkd/account/signShareAccount.action",
`jsondata=${escape(JSON.stringify(body))}`), async (err, resp, data) => {
try {
if (err) {
$.log(`${JSON.stringify(err)}`)
$.log(`${$.name} API请求失败,请检查网路重试`)
} else {
if (safeGet(data)) {
data = JSON.parse(data);
if (data['ret'] === 'ok') {
$.log(`签到分享成功,获得 ${data.profit} 金币`)
$.profit += data.profit
if (data.advertPopup && data.advertPopup.advert) {
$.log(`去做额外【${data.advertPopup.buttonText}】任务`)
await adv(data.advertPopup.position)
}
} else if (data['ret'] === 'fail') {
$.log(`签到失败,错误信息:${data.rtn_msg}`)
} else {
$.log(`未知错误:${JSON.stringify(data)}`)
}
}
}
} catch (e) {
$.logErr(e, resp)
} finally {
resolve(data);
}
})
})
}
function adv(position) {
if ($.scf) return
let body = {
"openid": $.openId,
"channel": $.iOS ? "iOS" : "android",
"os": $.iOS ? "iOS" : "android",
"appversioncode": `${$.version}`,
"time": `${new Date().getTime()}`,
"psign": "92dea068b6c271161be05ed358b59932",
"position": position,
"apptoken": "xzwltoken070704",
"appid": "xzwl",
"appversion": fakeIOS ? '5.6.5' : $.version.toString().split('').join('.'),
}
return new Promise(resolve => {
$.post(taskPostUrl("jkd/newmobile/stimulateAdv.action",
`jsondata=${escape(JSON.stringify(body))}`), async (err, resp, data) => {
try {
if (err) {
$.log(`${JSON.stringify(err)}`)
$.log(`${$.name} API请求失败,请检查网路重试`)
} else {
if (safeGet(data)) {
data = JSON.parse(data);
if (data['ret'] === 'ok') {
$.log(`点击视频成功,预计获得 ${data.rewardAmount ? data.rewardAmount : 0} 金币,等待 30 秒`)
await $.wait(31 * 1000)
body['time'] = `${new Date().getTime()}`
await rewardAdv(body)
} else if (data['ret'] === 'fail') {
$.log(`点击视频失败,错误信息:${data.rtn_msg}`)
} else {
$.log(`未知错误:${JSON.stringify(data)}`)
}
}
}
} catch (e) {
$.logErr(e, resp)
} finally {
resolve(data);
}
})
})
}
function rewardAdv(body) {
return new Promise(resolve => {
$.post(taskPostUrl("jkd/account/stimulateAdvAccount.action",
`jsondata=${escape(JSON.stringify(body))}`), async (err, resp, data) => {
try {
if (err) {
$.log(`${JSON.stringify(err)}`)
$.log(`${$.name} API请求失败,请检查网路重试`)
} else {
if (safeGet(data)) {
data = JSON.parse(data);
if (data['ret'] === 'ok') {
$.log(`观看视频成功,获得 ${data.profit} 金币`)
$.profit += data.profit
} else if (data['ret'] === 'fail') {
$.log(`观看视频失败,错误信息:${data.rtn_msg}`)
} else {
$.log(`未知错误:${JSON.stringify(data)}`)
}
}
}
} catch (e) {
$.logErr(e, resp)
} finally {
resolve(data);
}
})
})
}
function getArticleList(categoryId = 3) {
let body = {
"appid": "xzwl",
"connectionType": 100,
"optaction": "down",
"pagesize": 12,
"channel": $.iOS ? "iOS" : "android",
"psign": "92dea068b6c271161be05ed358b59932",
"appversioncode": $.version,
"time": "1609437200",
"apptoken": "xzwltoken070704",
"cateid": categoryId,
"openid": $.openId,
"os": $.iOS ? "iOS" : "android",
"appversion": fakeIOS ? '5.6.5' : $.version.toString().split('').join('.'),
"operatorType": 2,
"page": 12
}
return new Promise(resolve => {
$.post(taskPostUrl("jkd/newmobile/artlist.action",
`jsondata=${escape(JSON.stringify(body))}`),
async (err, resp, data) => {
try {
if (err) {
$.log(`${JSON.stringify(err)}`)
$.log(`${$.name} API请求失败,请检查网路重试`)
} else {
if (safeGet(data)) {
data = JSON.parse(data);
if (data['ret'] === 'ok') {
$.artList = data.artlist
}
}
}
} catch (e) {
$.logErr(e, resp)
} finally {
resolve(data);
}
})
})
}
function openTimeBox() {
let body = {
"openid": $.openId,
"channel": $.iOS ? "iOS" : "android",
"os": $.iOS ? "iOS" : "android",
"appversioncode": `${$.version}`,
"time": `${new Date().getTime()}`,
"psign": "92dea068b6c271161be05ed358b59932",
"apptoken": "xzwltoken070704",
"appid": "xzwl",
"appversion": fakeIOS ? '5.6.5' : $.version.toString().split('').join('.'),
}
return new Promise(resolve => {
$.post(taskPostUrl("jkd/account/openTimeBoxAccount.action",
`jsondata=${escape(JSON.stringify(body))}`), async (err, resp, data) => {
try {
if (err) {
$.log(`${JSON.stringify(err)}`)
$.log(`${$.name} API请求失败,请检查网路重试`)
} else {
if (safeGet(data)) {
data = JSON.parse(data);
if (data['ret'] === 'ok') {
$.log(`宝箱奖励领取成功,获得 ${data.profit} 金币`)
$.profit += data.profit
if (data.advertPopup && data.advertPopup.position) {
$.log(`去做额外【${data.advertPopup.buttonText}】任务`)
await adv(data.advertPopup.position)
}
} else if (data['ret'] === 'fail') {
$.log(`签到失败,错误信息:${data.rtn_msg}`)
} else {
$.log(`未知错误:${JSON.stringify(data)}`)
}
}
}
} catch (e) {
$.logErr(e, resp)
} finally {
resolve(data);
}
})
})
}
function getArticle(artId) {
let body = {
"time": `${new Date().getTime()}`,
"apptoken": "xzwltoken070704",
"appversion": fakeIOS ? '5.6.5' : $.version.toString().split('').join('.'),
"openid": $.openId,
"channel": $.iOS ? "iOS" : "android",
"os": $.iOS ? "iOS" : "android",
"psign": "92dea068b6c271161be05ed358b59932",
"artid": artId,
"appid": "xzwl"
}
return new Promise(resolve => {
$.post(taskPostUrl("jkd/newmobile/articleDetail.action",
`jsondata=${escape(JSON.stringify(body))}`), async (err, resp, data) => {
try {
if (err) {
$.log(`${JSON.stringify(err)}`)
$.log(`${$.name} API请求失败,请检查网路重试`)
} else {
if (safeGet(data)) {
data = JSON.parse(data);
if (data['ret'] === 'ok') {
$.log(`articleDetail 记录成功`)
}
}
}
} catch (e) {
$.logErr(e, resp)
} finally {
resolve(data);
}
})
})
}
function getVideo(artId) {
let body = {
"appid": "xzwl",
"channel": $.iOS ? "iOS" : "android",
"psign": "92dea068b6c271161be05ed358b59932",
"appversioncode": $.version.toString(),
"time": new Date().getTime().toString(),
"apptoken": "xzwltoken070704",
"requestid": new Date().getTime().toString(),
"openid": $.openId,
"os": $.iOS ? "iOS" : "android",
"artid": artId,
"appversion": fakeIOS ? '5.6.5' : $.version.toString().split('').join('.'),
"relate": "1",
"scenetype": ""
}
return new Promise(resolve => {
$.post(taskPostUrl("jkd/newmobile/artDetail.action",
`jsondata=${escape(JSON.stringify(body))}`), async (err, resp, data) => {
try {
if (err) {
$.log(`${JSON.stringify(err)}`)
$.log(`${$.name} API请求失败,请检查网路重试`)
} else {
if (safeGet(data)) {
data = JSON.parse(data);
if (data['ret'] === 'ok') {
$.log(`artDetail 记录成功`)
}
}
}
} catch (e) {
$.logErr(e, resp)
} finally {
resolve(data);
}
})
})
}
function getStageReward(stage) {
return new Promise(resolve => {
$.post(taskPostUrl("jkd/weixin20/newactivity/getStageReward.action",
`stage=${stage}`), async (err, resp, data) => {
try {
if (err) {
$.log(`${JSON.stringify(err)}`)
$.log(`${$.name} API请求失败,请检查网路重试`)
} else {
if (safeGet(data)) {
data = JSON.parse(data);
if (data['ret'] === 'ok') {
$.log(`阶段奖励${stage}获取成功,获得 ${data.profit} 金币`)
$.profit += data.profit
} else if (data['ret'] === 'fail') {
$.log(`阶段奖励获取失败,错误信息:${data.rtn_msg}`)
} else {
$.log(`未知错误:${JSON.stringify(data)}`)
}
}
}
} catch (e) {
$.logErr(e, resp)
} finally {
resolve(data);
}
})
})
}
function call2(uuid, opttype = "ART_READ") {
let body = {
"openID": $.openId,
"openid": $.openId,