forked from wliustc/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jd_19E_help.js
3662 lines (3605 loc) · 170 KB
/
jd_19E_help.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
/*
建议手动先点开一次
10 0,6-21/5 * * * jd_19E_help.js
*/
const CryptoJS = require("crypto-js");
const $ = new Env('热爱奇旅互助版-部分加密');
const notify = $.isNode() ? require('./sendNotify') : '';
//Node.js用户请在jdCookie.js处填写京东ck;
let cookiesArr = [], cookie = '', message, helpCodeArr = [], helpPinArr = [], wxCookie = "";
let wxCookieArr = process.env.WXCookie?.split("@") || []
const teamLeaderArr = [], teamPlayerAutoTeam = {}
const jdCookieNode = $.isNode() ? require('./jdCookie.js') : '';
let appid = '50074'
var timestamp = Math.round(new Date().getTime()).toString();
$.curlCmd = ""
const h = (new Date()).getHours()
const helpFlag = h >= 9 && h < 12
const puzzleFlag = h >= 13 && h < 18
if ($.isNode()) {
Object.keys(jdCookieNode).forEach((item) => {
cookiesArr.push(jdCookieNode[item])
})
if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { };
} else {
cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item);
}
const pkTeamNum = Math.ceil(cookiesArr.length / 30)
const JD_API_HOST = 'https://api.m.jd.com/client.action';
!(async () => {
if (!cookiesArr[0]) {
$.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', { "open-url": "https://bean.m.jd.com/bean/signIndex.action" });
return;
}
console.log(`\n自行测试,部分加密\n来源于其他作者,自行衡量是否跑不跑!\n`);
const helpSysInfoArr = []
for (let i = 0; i < cookiesArr.length; i++) {
if (cookiesArr[i]) {
cookie = cookiesArr[i];
wxCookie = wxCookieArr[i] ?? "";
const pt_key = cookie.match(/pt_key=([^; ]+)(?=;?)/)?.[1] || ""
if (!/app_open/.test(pt_key)) {
//getAppCookie && (cookie = await getAppCookie(cookie));
}
$.pin = cookie.match(/pt_pin=([^; ]+)(?=;?)/)?.[1] || ""
$.UserName = decodeURIComponent($.pin)
$.index = i + 1;
$.isLogin = true;
$.nickName = $.UserName;
$.startActivityTime = Date.now().toString() + randomNum(1e8).toString()
message = '';
await TotalBean();
console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`);
if (!$.isLogin) {
$.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, { "open-url": "https://bean.m.jd.com/bean/signIndex.action" });
if ($.isNode()) {
await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`);
}
continue
}
$.UA = getUA()
$.shshshfpb = randomUUID({
formatData: "x".repeat(23),
charArr: [
...[...Array(10).keys()].map(x => String.fromCharCode(x + 48)),
...[...Array(26).keys()].map(x => String.fromCharCode(x + 97)),
...[...Array(26).keys()].map(x => String.fromCharCode(x + 65)),
"/"
],
followCase: false
}) + "==";
$.__jd_ref_cls = "Babel_dev_adv_selfReproduction"
// $.ZooFaker = utils({ $ })
$.joyytoken = await getToken()
$.blog_joyytoken = await getToken("50999", "4")
// cookie = $.ZooFaker.getCookie(cookie + `joyytoken=${appid}${$.joyytoken};`)
await travel()
helpSysInfoArr.push({
cookie,
pin: $.UserName,
UA: $.UA,
joyytoken: $.joyytoken,
blog_joyytoken: $.blog_joyytoken,
secretp: $.secretp
})
}
}
//
$.subSceneid = "RAhomePageh5"
for (let i = 0; i < helpSysInfoArr.length; i++) {
const s = helpSysInfoArr[i]
cookie = s.cookie
$.UserName = s.pin
$.index = i + 1;
$.isLogin = true;
$.nickName = $.UserName;
await TotalBean();
console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`);
if (!$.isLogin) continue
$.UA = s.UA
//$.ZooFaker = utils()
$.joyytoken = s.joyytoken
$.blog_joyytoken = s.blog_joyytoken
$.secretp = s.secretp
//if (helpFlag) {
$.newHelpCodeArr = [...helpCodeArr]
for (let i = 0, codeLen = helpCodeArr.length; i < codeLen; i++) {
const helpCode = helpCodeArr[i]
const { pin, code } = helpCode
if (pin === $.UserName) continue
console.log(`去帮助用户:${pin}`)
const helpRes = await doApi("collectScore", null, { inviteId: code }, true, true)
if (helpRes?.result?.score) {
const { alreadyAssistTimes, maxAssistTimes, maxTimes, score, times } = helpRes.result
const c = maxAssistTimes - alreadyAssistTimes
console.log(`互助成功,获得${score}金币,他还需要${maxTimes - times}人完成助力,你还有${maxAssistTimes - alreadyAssistTimes}次助力机会`)
if (!c) break
} else {
if (helpRes?.bizCode === -201) {
$.newHelpCodeArr = $.newHelpCodeArr.filter(x => x.pin !== pin)
}
console.log(`互助失败,原因:${helpRes?.bizMsg}(${helpRes?.bizCode})`)
if (![0, -201, -202].includes(helpRes?.bizCode)) break
}
}
helpCodeArr = [...$.newHelpCodeArr]
//}
// $.joyytoken = ""
// cookie = cookie.replace(/joyytoken=\S+?;/, "joyytoken=;")
if (teamPlayerAutoTeam.hasOwnProperty($.UserName)) {
const { groupJoinInviteId, groupNum, groupName } = teamLeaderArr[teamPlayerAutoTeam[$.UserName]]
console.log(`${groupName}人数:${groupNum},正在去加入他的队伍...`)
await joinTeam(groupJoinInviteId)
teamLeaderArr[teamPlayerAutoTeam[$.UserName]].groupNum += 1
await $.wait(2000)
}
}
})()
.catch((e) => {
$.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '')
}).finally(() => {
$.done();
})
async function travel() {
try {
const mainMsgPopUp = await doApi("getMainMsgPopUp", { "channel": "1" })
mainMsgPopUp?.score && formatMsg(mainMsgPopUp.score, "首页弹窗")
const homeData = await doApi("getHomeData")
// console.log(homeData)
if (homeData) {
const { homeMainInfo: { todaySignStatus, secretp } } = homeData
if (secretp) $.secretp = secretp
if (!todaySignStatus) {
const { awardResult, nextRedPacketDays, progress, scoreResult } = await doApi("sign", null, null, true)
let ap = []
for (let key in awardResult || {}) {
if (key === "couponResult") {
const { usageThreshold, quota, desc } = awardResult[key]
ap.push(`获得优惠券:满${usageThreshold || 0}减${quota || 0}(${desc})`)
} else if (key === "redPacketResult") {
const { value } = awardResult[key]
ap.push(`获得红包:${value}元`)
} else {
ap.push(`获得未知东东(${key}):${JSON.stringify(awardResult[key])}`)
}
}
ap.push(`还需签到${nextRedPacketDays}天获得红包`)
ap.push(`签到进度:${progress}`)
scoreResult?.score && formatMsg(scoreResult.score, "每日签到", ap.join(","))
}
const collectAutoScore = await doApi("collectAutoScore", null, null, true)
collectAutoScore.produceScore && formatMsg(collectAutoScore.produceScore, "定时收集")
console.log("\n去做主App任务\n")
await doAppTask()
//console.log("\n去看看战队\n")
const pkHomeData = await doApi("pk_getHomeData")
const pkPopArr = await doApi("pk_getMsgPopup") || []
for (const pkPopInfo of pkPopArr) {
if (pkPopInfo?.type === 50 && pkPopInfo.value) {
const pkDivideInfo = await doApi("pk_divideScores", null, null, true)
pkDivideInfo?.produceScore && formatMsg(pkDivideInfo?.produceScore, "PK战队瓜分收益")
}
}
const { votInfo } = pkHomeData
if (votInfo) {
const { groupPercentA, groupPercentB, packageA, packageB, status } = votInfo
if (status === 2) {
let a = (+ packageA / + groupPercentA).toFixed(3)
let b = (+ packageB / + groupPercentB).toFixed(3)
const vot = a > b ? "A" : "B"
console.log(`'A'投票平均收益:${a},'B'投票平均收益:${b},去投:${vot}`)
await votFor(vot)
}
}
const { groupJoinInviteId, groupName, groupNum } = pkHomeData?.groupInfo || {}
if (groupNum !== undefined && groupNum < 30 && $.index <= pkTeamNum) {
if (groupJoinInviteId) {
teamLeaderArr.push({
groupJoinInviteId,
groupNum,
groupName
})
}
} else if (groupNum === 1) {
const n = ($.index - 1) % pkTeamNum
if (teamLeaderArr[n]) {
teamPlayerAutoTeam[$.UserName] = n
}
}
//if (puzzleFlag) {
// console.log("\n去做做拼图任务")
// const { doPuzzle } = require('./jd_travel_puzzle')
// await doPuzzle($, cookie)
//}
}
} catch (e) {
console.log(e)
}
// if (helpFlag) {
// try {
// $.WxUA = getWxUA()
// const WxHomeData = await doWxApi("getHomeData", { inviteId: "" })
// $.WxSecretp = WxHomeData?.homeMainInfo?.secretp || $.secretp
// console.log("\n去做微信小程序任务\n")
// await doWxTask()
// } catch (e) {
// console.log(e)
// }
// try {
// console.log("\n去做金融App任务\n")
// $.sdkToken = "jdd01" + randomUUID({
// formatData: "X".repeat(103),
// charArr: [...Array(36).keys()].map(k => k.toString(36).toUpperCase())
// }) + "0123456"
// await doJrAppTask()
// } catch (e) {
// console.log(e)
// }
// }
try {
//await raise(true)
} catch (e) {
console.log(e)
}
}
async function joinTeam(groupJoinInviteId) {
const inviteId = groupJoinInviteId
await doApi("pk_getHomeData", { inviteId })
const { bizCode, bizMsg } = await doApi("pk_joinGroup", { inviteId, confirmFlag: "1" }, null, true, true)
if (bizCode === 0) {
console.log("加入队伍成功!")
} else {
formatErr("pk_joinGroup", `${bizMsg}(${bizCode})`, $.curlCmd)
}
}
async function votFor(votFor) {
const { bizCode, bizMsg } = await doApi("pk_votFor", { votFor }, null, false, true)
if (bizCode === 0) {
console.log("投票成功!")
} else {
formatErr("pk_votFor", `${bizMsg}(${bizCode})`, $.curlCmd)
}
}
async function raise(isFirst = false) {
const homeData = await doApi("getHomeData")
// console.log(homeData)
if (!homeData) return
const { homeMainInfo: { raiseInfo: { cityConfig: { clockNeedsCoins, points }, remainScore } } } = homeData
if (remainScore >= clockNeedsCoins) {
if (isFirst) console.log(`\n开始解锁\n`)
let curScore = remainScore
let flag = false
for (const { status, pointName } of points) {
if (status === 1) {
const res = await doApi("raise", {}, {}, true)
if (res) {
if (!flag) flag = true
let arr = [`解锁'${pointName}'成功`]
const { levelUpAward: { awardCoins, canFirstShare, couponInfo, firstShareAwardCoins, redNum } } = res
arr.push(`获得${awardCoins}个金币`)
if (couponInfo) {
arr.push(`获得【${couponInfo.name}】优惠券:满${couponInfo.usageThreshold}减${couponInfo.quota}(${couponInfo.desc})`)
}
if (redNum) {
arr.push(`获得${redNum}份分红`)
}
console.log(arr.join(","))
if (canFirstShare) {
const WelfareScore = await doApi("getWelfareScore", { type: 1 })
if (WelfareScore?.score) formatMsg(WelfareScore?.score, "分享收益")
}
curScore -= clockNeedsCoins
if (curScore < clockNeedsCoins) return
} else {
return
}
}
await $.wait(2000)
}
if (flag) await raise()
}
}
async function doAppTask() {
const { inviteId, lotteryTaskVos, taskVos } = await doApi("getTaskDetail")
if (inviteId) {
console.log(`你的互助码:${inviteId}`)
if (!helpPinArr.includes($.UserName)) {
helpCodeArr.push({
pin: $.UserName,
code: inviteId
})
helpPinArr.push($.UserName)
}
}
for (const { times, badgeAwardVos } of lotteryTaskVos || []) {
for (const { awardToken, requireIndex, status } of badgeAwardVos) {
if (times >= requireIndex && status === 3) {
const res = await doApi("getBadgeAward", { awardToken })
if (res?.score) {
formatMsg(res.score, "奖励宝箱收益")
} else {
const myAwardVos = mohuReadJson(res, "Vos?$", 1)
if (myAwardVos) {
let flag = false
for (let award of myAwardVos) {
const awardInfo = mohuReadJson(award, "Vos?$", -1, "score")
if (awardInfo?.score) {
if (!flag) flag = true
formatMsg(awardInfo.score, "奖励宝箱收益")
}
}
if (!flag) console.log(res)
}
}
}
}
}
const feedList = []
for (let mainTask of taskVos) {
// console.log(mainTask)
const { taskId, taskName, waitDuration, times: timesTemp, maxTimes, status } = mainTask
if (status === 2) continue
let times = timesTemp, flag = false
const other = mohuReadJson(mainTask, "Vos?$", -1, "taskToken")
if (other) {
const { taskToken } = other
if (!taskToken) continue
if (taskId === 1) {
continue
}
console.log(`当前正在做任务:${taskName}`)
const body = { taskId, taskToken, actionType: 1 }
if (taskId === 31) {
await doApi("pk_getHomeData")
await doApi("pk_getPkTaskDetail", null, null, false, true)
await doApi("pk_getMsgPopup")
delete body.actionType
}
const res = await doApi("collectScore", { taskId, taskToken, actionType: 1 }, null, true)
res?.score && (formatMsg(res.score, "任务收益"), true)/* || console.log(res) */
continue
}
$.stopCard = false
for (let activity of mohuReadJson(mainTask, "Vo(s)?$", maxTimes, "taskToken") || []) {
if (!flag) flag = true
const { shopName, title, taskToken, status } = activity
if (status !== 1) continue
console.log(`当前正在做任务:${shopName || title}`)
const res = await doApi("collectScore", { taskId, taskToken, actionType: 1 }, null, true)
if ($.stopCard) break
if (waitDuration || res.taskToken) {
await $.wait(waitDuration * 1000)
const res = await doApi("collectScore", { taskId, taskToken, actionType: 0 }, null, true)
res?.score && (formatMsg(res.score, "任务收益"), true)/* || console.log(res) */
} else {
res?.score && (formatMsg(res.score, "任务收益"), true)/* || console.log(res) */
}
times++
if (times >= maxTimes) break
}
if (flag) continue
feedList.push({
taskId: taskId.toString(),
taskName
})
}
for (let feed of feedList) {
const { taskId: id, taskName: name } = feed
const res = await doApi("getFeedDetail", { taskId: id.toString() })
if (!res) continue
for (let mainTask of mohuReadJson(res, "Vos?$", 1, "taskId") || []) {
const { score, taskId, taskBeginTime, taskEndTime, taskName, times: timesTemp, maxTimes, waitDuration } = mainTask
const t = Date.now()
let times = timesTemp
if (t >= taskBeginTime && t <= taskEndTime) {
console.log(`当前正在做任务:${taskName}`)
for (let productInfo of mohuReadJson(mainTask, "Vo(s)?$", maxTimes, "taskToken") || []) {
const { taskToken, status } = productInfo
if (status !== 1) continue
const res = await doApi("collectScore", { taskId, taskToken, actionType: 1 }, null, true)
times = res?.times ?? (times + 1)
await $.wait(waitDuration * 1000)
if (times >= maxTimes) {
formatMsg(score, "任务收益")
break
}
}
}/* else {
console.log(`任务:${taskName}:未到做任务时间`)
} */
}
}
}
async function doWxTask() {
$.stopWxTask = false
const feedList = []
const { taskVos } = await doWxApi("getTaskDetail", { taskId: "", appSign: 2 })
for (let mainTask of taskVos) {
const { taskId, taskName, waitDuration, times: timesTemp, maxTimes, status } = mainTask
let times = timesTemp, flag = false
if (status === 2) continue
const other = mohuReadJson(mainTask, "Vos?$", -1, "taskToken")
if (other) {
const { taskToken } = other
if (!taskToken) continue
if (taskId === 1) {
continue
}
console.log(`当前正在做任务:${taskName}`)
const res = await doWxApi("collectScore", { taskId, taskToken, actionType: 1 }, null, true)
if ($.stopWxTask) return
res?.score && (formatMsg(res.score, "任务收益"), true)/* || console.log(res) */
continue
}
$.stopCard = false
for (let activity of mohuReadJson(mainTask, "Vo(s)?$", maxTimes, "taskToken") || []) {
if (!flag) flag = true
const { shopName, title, taskToken, status } = activity
if (status !== 1) continue
console.log(`当前正在做任务:${shopName || title}`)
const res = await doWxApi("collectScore", { taskId, taskToken, actionType: 1 }, null, true)
if ($.stopCard || $.stopWxTask) break
if (waitDuration || res.taskToken) {
await $.wait(waitDuration * 1000)
const res = await doWxApi("collectScore", { taskId, taskToken, actionType: 0 }, null, true)
if ($.stopWxTask) return
res?.score && (formatMsg(res.score, "任务收益"), true)/* || console.log(res) */
} else {
if ($.stopWxTask) return
res?.score && (formatMsg(res.score, "任务收益"), true)/* || console.log(res) */
}
times++
if (times >= maxTimes) break
}
if (flag) continue
feedList.push({
taskId: taskId.toString(),
taskName
})
}
for (let feed of feedList) {
const { taskId: id, taskName: name } = feed
const res = await doWxApi("getFeedDetail", { taskId: id.toString() }, null, true)
if (!res) continue
for (let mainTask of mohuReadJson(res, "Vos?$", 1, "taskId") || []) {
const { score, taskId, taskBeginTime, taskEndTime, taskName, times: timesTemp, maxTimes, waitDuration } = mainTask
const t = Date.now()
let times = timesTemp
if (t >= taskBeginTime && t <= taskEndTime) {
console.log(`当前正在做任务:${taskName}`)
for (let productInfo of mohuReadJson(mainTask, "Vo(s)?$", maxTimes, "taskToken") || []) {
const { taskToken, status } = productInfo
if (status !== 1) continue
const res = await doWxApi("collectScore", { taskId, taskToken, actionType: 1 }, null, true)
if ($.stopWxTask) return
times = res?.times ?? (times + 1)
await $.wait(waitDuration * 1000)
if (times >= maxTimes) {
formatMsg(score, "任务收益")
break
}
}
}/* else {
console.log(`任务:${taskName}:未到做任务时间`)
} */
}
}
}
async function doJrAppTask() {
$.isJr = true
$.JrUA = getJrUA()
const { trades, views } = await doJrPostApi("miMissions", null, null, true)
/* for (let task of trades || views || []) {
const { status, missionId, channel } = task
if (status !== 1 && status !== 3) continue
const { subTitle, title, url } = await doJrPostApi("miTakeMission", null, {
missionId,
validate: "",
channel,
babelChannel: "1111shouyefuceng"
}, true)
console.log(`当前正在做任务:${title},${subTitle}`)
const { code, msg, data } = await doJrGetApi("queryPlayActiveHelper", { sourceUrl: url })
// const { code, msg, data } = await doJrGetApi("queryMissionReceiveAfterStatus", { missionId })
console.log(`做任务结果:${msg}(${code})`)
} */
for (let task of views || []) {
const { status, missionId, channel, total, complete } = task
if (status !== 1 && status !== 3) continue
const { subTitle, title, url } = await doJrPostApi("miTakeMission", null, {
missionId,
validate: "",
channel,
babelChannel: "1111zhuhuichangfuceng"
}, true)
console.log(`当前正在做任务:${title},${subTitle}`)
const readTime = url.getKeyVal("readTime")
const juid = url.getKeyVal("juid")
if (readTime) {
await doJrGetApi("queryMissionReceiveAfterStatus", { missionId })
await $.wait(+ readTime * 1000)
const { code, msg, data } = await doJrGetApi("finishReadMission", { missionId, readTime })
console.log(`做任务结果:${msg}`)
} else if (juid) {
const { code, msg, data } = await doJrGetApi("getJumpInfo", { juid })
console.log(`做任务结果:${msg}`)
} else {
console.log(`不知道这是啥:${url}`)
}
}
$.isJr = false
}
function mohuReadJson(json, key, len, keyName) {
if (!key) return null
for (let jsonKey in json) {
if (RegExp(key).test(jsonKey)) {
if (!len) return json[jsonKey]
if (len === -1) {
if (json[jsonKey][keyName]) return json[jsonKey]
} else if (json[jsonKey]?.length >= len) {
if (keyName) {
if (json[jsonKey][0].hasOwnProperty(keyName)) {
return json[jsonKey]
} else {
continue
}
}
return json[jsonKey]
}
}
}
return null
}
function formatMsg(num, pre, ap) {
console.log(`${pre ? pre + ":" : ""}获得${num}个金币🪙${ap ? "," + ap : ""}`)
}
function getSs(secretp) {
$.random = 53554918
$.sceneid = $.subSceneid ?? "RAhomePageh5"
const extraData = getBody(53554918)
return {
extraData,
secretp,
random: $.random
}
}
function getSafeStr() {
$.random = 53554918
const log = getBody(53554918)
return {
random: $.random,
secreid: "HYJGJSh5",
log
}
}
function getWxSs(secretp) {
$.random = 53554918
$.secreid = "HYJhPagewx"
const extraData = getBody(53554918)
return {
extraData,
secretp,
random: $.random
}
}
async function doApi(functionId, prepend = {}, append = {}, needSs = false, getLast = false) {
functionId = `promote_${functionId}`
const url = JD_API_HOST + `?functionId=${functionId}`
const bodyMain = objToStr2({
functionId,
body: encodeURIComponent(JSON.stringify({
...prepend,
ss: needSs ? JSON.stringify(getSs($.secretp || "E7CRMoDURcyS-_XDYYuo__Ai9oE")) : undefined,
...append,
})),
client: "m",
clientVersion: "1.0.0",
appid :"signed_wh5"
})
const option = {
url,
body: bodyMain,
headers: {
'Cookie': cookie,
'Host': 'api.m.jd.com',
'Origin': 'https://wbbny.m.jd.com',
'Referer': 'https://wbbny.m.jd.com/babelDiy/Zeus/2vVU4E7JLH9gKYfLQ5EVW6eN2P7B/index.html',
'Connection': 'keep-alive',
'Content-Type': 'application/x-www-form-urlencoded',
"User-Agent": $.UA,
'Accept': 'application/json, text/plain, */*',
'Accept-Language': 'zh-cn',
'Accept-Encoding': 'gzip, deflate, br',
}
}
$.curlCmd = toCurl(option)
return new Promise(resolve => {
$.post(option, (err, resp, data) => {
let res = null
try {
if (err) console.log(formatErr(functionId, err, toCurl(option)))
else {
if (safeGet(data)) {
data = JSON.parse(data)
if (getLast) {
res = data?.data
if (data?.data?.bizCode === -1002) {
console.log(formatErr(functionId, data, toCurl(option)))
}
} else {
if (data?.data?.bizCode !== 0) {
if (/加入.*?会员.*?获得/.test(data?.data?.bizMsg)) {
console.log(data?.data?.bizMsg + `(${data?.data?.bizCode})`)
$.stopCard = true
} else console.log(formatErr(data?.data?.bizMsg + `(${data?.data?.bizCode})`))
} else {
res = data?.data?.result || {}
}
}
} else {
console.log(formatErr(functionId, data, toCurl(option)))
}
}
} catch (e) {
console.log(formatErr(functionId, e.toString(), toCurl(option)))
} finally {
resolve(res)
}
})
})
}
async function doJrPostApi(functionId, prepend = {}, append = {}, needEid = false) {
const url = "https://ms.jr.jd.com/gw/generic/uc/h5/m/" + functionId
const bodyMain = `reqData=${encodeURIComponent(JSON.stringify({
...prepend,
...needEid ? {
eid: $.eid || "",
sdkToken: $.sdkToken || "",
} : {},
...append
}))}`
const option = {
url,
body: bodyMain,
headers: {
'Cookie': cookie,
'Host': 'ms.jr.jd.com',
'Origin': 'https://wbbny.m.jd.com',
'Referer': 'https://wbbny.m.jd.com/babelDiy/Zeus/2vVU4E7JLH9gKYfLQ5EVW6eN2P7B/index.html?babelChannel=1111zhuhuichangfuceng&conf=jr',
'Connection': 'keep-alive',
'Content-Type': 'application/x-www-form-urlencoded',
"User-Agent": $.JrUA,
'Accept': 'application/json, text/plain, */*',
'Accept-Language': 'zh-cn',
'Accept-Encoding': 'gzip, deflate, br',
}
}
return new Promise(resolve => {
$.post(option, (err, resp, data) => {
let res = null
try {
if (err) console.log(formatErr(functionId, err, toCurl(option)))
else {
if (safeGet(data)) {
data = JSON.parse(data)
if (data?.resultData?.code !== 0) {
console.log(formatErr(functionId, data?.resultData?.msg + `(${data?.resultData?.code})`, toCurl(option)))
} else {
res = data?.resultData?.data || {}
}
} else {
console.log(formatErr(functionId, data, toCurl(option)))
}
}
} catch (e) {
console.log(formatErr(functionId, e.toString(), toCurl(option)))
} finally {
resolve(res)
}
})
})
}
async function doJrGetApi(functionId, prepend = {}, append = {}, needEid = false) {
const url = "https://ms.jr.jd.com/gw/generic/mission/h5/m/" + functionId
const bodyMain = `reqData=${encodeURIComponent(JSON.stringify({
...prepend,
...needEid ? {
eid: $.eid || "",
sdkToken: $.sdkToken || "",
} : {},
...append
}))}`
const option = {
url: `${url}?${bodyMain}`,
headers: {
'Cookie': cookie,
'Host': 'ms.jr.jd.com',
'Origin': 'https://wbbny.m.jd.com',
'Referer': 'https://wbbny.m.jd.com/babelDiy/Zeus/2vVU4E7JLH9gKYfLQ5EVW6eN2P7B/index.html?babelChannel=1111shouyefuceng&conf=jr',
'Connection': 'keep-alive',
'Content-Type': 'application/x-www-form-urlencoded',
"User-Agent": $.JrUA,
'Accept': '*/*',
'Accept-Language': 'zh-cn',
'Accept-Encoding': 'gzip, deflate, br',
}
}
return new Promise(resolve => {
$.get(option, (err, resp, data) => {
let res = null
try {
if (err) console.log(formatErr(functionId, err, toCurl(option)))
else {
if (safeGet(data)) {
data = JSON.parse(data)
res = data?.resultData || {}
} else {
console.log(formatErr(functionId, data, toCurl(option)))
}
}
} catch (e) {
console.log(formatErr(functionId, e.toString(), toCurl(option)))
} finally {
resolve(res)
}
})
})
}
async function doWxApi(functionId, prepend = {}, append = {}, needSs = false) {
functionId = `promote_${functionId}`
const url = JD_API_HOST + `?dev=${functionId}&g_ty=ls&g_tk=`
const bodyMain = {
sceneval: "",
callback: functionId,
functionId,
appid: "wh5",
client: "wh5",
clientVersion: "1.0.0",
uuid: -1,
body: encodeURIComponent(JSON.stringify({
...prepend,
ss: needSs ? JSON.stringify(getWxSs($.WxSecretp)) : undefined,
...append,
})),
loginType: 2,
loginWQBiz: "dacu"
}
const cookieA =
wxCookie
?
((bodyMain.loginType = 1), `jdpin=${$.pin};pin=${$.pin};pinStatus=0;wq_auth_token=${wxCookie};shshshfpb=${encodeURIComponent($.shshshfpb)};`)
:
cookie
const option = {
url,
body: objToStr2(bodyMain),
headers: {
'Cookie': cookieA,
'Host': 'api.m.jd.com',
'Referer': 'https://servicewechat.com/wx91d27dbf599dff74/570/page-frame.html',
'wxreferer': 'http://wq.jd.com/wxapp/pages/loveTravel/pages/index/index',
'Connection': 'keep-alive',
'Content-Type': 'application/x-www-form-urlencoded',
"User-Agent": $.WxUA,
'Accept': '*/*',
'Accept-Language': 'zh-cn',
'Accept-Encoding': 'gzip, deflate, br',
}
}
return new Promise(resolve => {
$.post(option, (err, resp, data) => {
let res = null
try {
if (err) console.log(formatErr(functionId, err, toCurl(option)))
else {
if (safeGet(data)) {
data = JSON.parse(data)
if (data?.data?.bizCode !== 0) {
if (data?.data?.bizCode === -1002) $.stopWxTask = true
console.log(formatErr(functionId, data?.data?.bizMsg ? (data?.data?.bizMsg + `(${data?.data?.bizCode})`) : JSON.stringify(data), toCurl(option)))
} else {
res = data.data.result
}
} else {
//console.log(formatErr(functionId, data, toCurl(option)))
}
}
} catch (e) {
console.log(formatErr(functionId, e.toString(), toCurl(option)))
} finally {
resolve(res)
}
})
})
}
function getToken(appname = appid, platform = "1") {
return new Promise(resolve => {
$.post({
url: "https://rjsb-token-m.jd.com/gettoken",
body: `content=${JSON.stringify({
appname,
whwswswws: "",
jdkey: $.UUID || randomString(40),
body: {
platform,
}
})}`,
headers: {
Accept: "*/*",
'Accept-Encoding': "gzip, deflate, br",
'Accept-Language': "zh-CN,zh-Hans;q=0.9",
Connection: "keep-alive",
'Content-Type': "text/plain;charset=UTF-8",
Host: "rjsb-token-m.jd.com",
Origin: "https://h5.m.jd.com",
Referer: "https://h5.m.jd.com/",
'User-Agent': $.UA
}
}, (err, resp, data) => {
try {
if (err) {
console.log(err)
resolve()
}
const { joyytoken } = JSON.parse(data)
resolve(joyytoken)
} catch (e) {
console.log(e)
resolve()
} finally {
}
})
})
}
function formatErr(functionId, errMsg, curlCmd) {
return JSON.parse(JSON.stringify({
functionId,
errMsg,
curlCmd,
}))
}
function safeGet(data) {
try {
if (typeof JSON.parse(data) == "object") {
return true;
}
} catch (e) {
console.log(e);
console.log(`京东服务器访问数据为空,请检查自身设备网络情况`);
return false;
}
}
function getUA() {
$.UUID = randomString(40)
const buildMap = {
"167814": `10.1.4`,
"167841": `10.1.6`,
"167853": `10.2.0`
}
$.osVersion = `${randomNum(13, 14)}.${randomNum(3, 6)}.${randomNum(1, 3)}`
let network = `network/${['4g', '5g', 'wifi'][randomNum(0, 2)]}`
$.mobile = `iPhone${randomNum(9, 13)},${randomNum(1, 3)}`
$.build = ["167814", "167841", "167853"][randomNum(0, 2)]
$.appVersion = buildMap[$.build]
return `jdapp;android;10.3.2`
}
function getWxUA() {
const osVersion = `${randomNum(12, 14)}.${randomNum(0, 6)}`
$.wxAppid = "wx91d27dbf599dff74"
return `Mozilla/5.0 (iPhone; CPU OS ${osVersion.replace(/\./g, "_")} like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.15(0x18000f28) NetType/WIFI Language/zh_CN`
}
function randomUUID(option = {
formatData: `${"X".repeat(8)}-${"X".repeat(4)}-${"X".repeat(4)}-${"X".repeat(12)}`,
charArr: [...Array(16).keys()].map(k => k.toString(16).toUpperCase()),
followCase: true,
}) {
if (!option.formatData) option.formatData = `${"X".repeat(8)}-${"X".repeat(4)}-${"X".repeat(4)}-${"X".repeat(12)}`
if (!option.charArr) option.charArr = [...Array(16).keys()].map(k => k.toString(16).toUpperCase())
if (!option.followCase === undefined) option.followCase = true
let { formatData: res, charArr } = option
res = res.split("")
const charLen = charArr.length - 1
const resLen = res.length
for (let i = 0; i < resLen; i++) {
const tis = res[i]
if (/[xX]/.test(tis)) {
res[i] = charArr[randomNum(0, charLen)]
if (option.followCase) res[i] = res[i][tis === "x" ? "toLowerCase" : "toUpperCase"]()
}
}
return res.join("")
}
function getJrUA() {
const randomMobile = {
type: `${randomNum(9, 13)},${randomNum(1, 3)}`,
screen: ["812", "375"]
}
const mobile = $.mobile ?? "iPhone " + randomMobile.type
const screen = randomMobile.screen.join('*')
const osV = $.osVersion ?? `${randomNum(13, 14)}.${randomNum(0, 6)}`
const appV = `6.2.40`
const deviceId = randomUUID({
formatData: 'x'.repeat(36) + '-' + 'x'.repeat(36),
charArr: [...Array(10).keys(), 'd'].map(x => x.toString())
})
const jdPaySdkV = `4.00.10.00`
return `Mozilla/5.0 (iPhone; CPU iPhone OS ${osV.replace(/\./g, "_")} AppleWebKit/60${randomNum(3, 5)}.1.15 (KHTML, like Gecko) Mobile/15E148/application=JDJR-App&deviceId=${deviceId}&eufv=1&clientType=ios&iosType=iphone&clientVersion=${appV}&HiClVersion=${appV}&isUpdate=0&osVersion=${osV}&osName=iOS&platform=${mobile}&screen=${screen}&src=App Store&netWork=1&netWorkType=1&CpayJS=UnionPay/1.0 JDJR&stockSDK=stocksdk-iphone_3.5.0&sPoint=&jdPay=(*#@jdPaySDK*#@jdPayChannel=jdfinance&jdPayChannelVersion=${osV}&jdPaySdkVersion=${jdPaySdkV}&jdPayClientName=iOS*#@jdPaySDK*#@)`
}
function toCurl(option = { url: "", body: "", headers: {} }) {
if (!option.url) return ""
let res = "curl "
if (!option.headers.Host) option.headers.Host = option.url.match(/^http(s)?:\/\/(.*?)($|\/)/)?.[2] || ""
for (let key in option.headers) {
res += `-H '${key}: ${option.headers[key]}' `
}
if (option.body) {
res += `--data-raw '${option.body}' `
}
res += `--compressed "${option.url}"`
return res
}
function objToStr2(jsonMap) {
let isFirst = true
let res = ""
for (let key in jsonMap) {
let keyValue = jsonMap[key]
if (typeof keyValue == "object") {
keyValue = JSON.stringify(keyValue)
}
if (isFirst) {
res += `${key}=${keyValue}`
isFirst = false
} else {
res += `&${key}=${keyValue}`
}
}
return res
}
function str2ToObj(keyMap) {
const keyArr = keyMap.split("&").filter(x => x)
const keyLen = keyArr.length
if (keyLen === 1 && !keyArr[0].includes("=")) {
return keyMap
}
const res = {}
for (let i = 0; i < keyLen; i++) {
const cur = keyArr[i].split('=').filter(x => x)
const curValue = cur[1]
if (/\d{1,16}|[.*?]|{}|{"\w+?":.*?(,"\w+?":.*?)*}|true|false/.test(curValue)) {