-
Notifications
You must be signed in to change notification settings - Fork 292
/
bot_jd_bean_change_QL.js
1813 lines (1713 loc) · 60.7 KB
/
bot_jd_bean_change_QL.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
/*
cron "0 0 * * *" bot_jd_bean_change.js, tag:机器人查询专用脚本
*/
//详细说明参考 https://github.com/ccwav/QLScript2
const $ = new Env('机器人查询专用脚本');
const JXUserAgent = $.isNode() ? (process.env.JX_USER_AGENT ? process.env.JX_USER_AGENT : ``) : ``;
//Node.js用户请在jdCookie.js处填写京东ck;
const jdCookieNode = $.isNode() ? require('./jdCookie.js') : '';
const axios = require('axios');
let NowHour = new Date().getHours();
let allMessage = '';
let allReceiveMessage = '';
let allWarnMessage = '';
let ReturnMessage = '';
let notifySkipList = "";
let isSignError = false;
let ReturnMessageTitle="";
//IOS等用户直接用NobyDa的jd cookie
let cookiesArr = [], cookie = '';
const JD_API_HOST = 'https://api.m.jd.com/client.action';
let intPerSent = 0;
let i = 0;
let Today = new Date();
let strAllNotify="";
let strSubNotify="";
let llPetError=false;
let strGuoqi="";
let RemainMessage = '';
let TempBaipiao = "";
let llgeterror=false;
let time = new Date().getHours();
const {getEnvByPtPin} = require('./ql');
let userIndex2 = -1;
let userIndex3 = -1;
let userIndex4 = -1;
let jdSignUrl = 'https://api.nolanstore.top/sign'
if (process.env.SIGNURL)
jdSignUrl = process.env.SIGNURL;
if ($.isNode()) {
Object.keys(jdCookieNode).forEach((item) => {
cookiesArr.push(jdCookieNode[item])
})
if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false')
console.log = () => {};
}
let intcheckckseq=999999;
let strcheckck = process.env.BOTCHECKCODE;
if(!strcheckck){
console.log("【账号🆔】没有获取到要查询的账号");
return
}
for (i = 0; i < cookiesArr.length; i++) {
if (cookiesArr[i]) {
cookie = cookiesArr[i];
$.pt_pin = (cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]);
if (strcheckck == $.pt_pin) {
intcheckckseq = i;
break;
}
}
}
if (intcheckckseq == 999999) {
if (IsNumber(strcheckck)) {
if (parseInt(strcheckck) > cookiesArr.length) {
console.log('【账号'+strcheckck+'🆔】你哪来那么多账号,没点逼数吗');
return
}
intcheckckseq = parseInt(strcheckck) - 1;
}
}
console.log("当前查询的CK序号是:"+(intcheckckseq+1));
//查询开关
let strDisableList = "";
let DisableIndex=-1;
if ($.isNode()) {
strDisableList = process.env.BEANCHANGE_BOTDISABLELIST ? process.env.BEANCHANGE_BOTDISABLELIST.split('&') : [];
}
//喜豆查询
let EnableJxBeans=true;
DisableIndex=strDisableList.findIndex((item) => item === "喜豆查询");
if(DisableIndex!=-1){
console.log("检测到设定关闭喜豆查询");
EnableJxBeans=false
}
//东东农场
let EnableJdFruit=true;
DisableIndex = strDisableList.findIndex((item) => item === "东东农场");
if(DisableIndex!=-1){
console.log("检测到设定关闭东东农场查询");
EnableJdFruit=false;
}
//极速金币
let EnableJdSpeed=true;
DisableIndex = strDisableList.findIndex((item) => item === "极速金币");
if(DisableIndex!=-1){
console.log("检测到设定关闭极速金币查询");
EnableJdSpeed=false;
}
//领现金
let EnableCash=true;
DisableIndex=strDisableList.findIndex((item) => item === "领现金");
if(DisableIndex!=-1){
console.log("检测到设定关闭领现金查询");
EnableCash=false;
}
//7天过期京豆
let EnableOverBean=true;
DisableIndex=strDisableList.findIndex((item) => item === "过期京豆");
if(DisableIndex!=-1){
console.log("检测到设定关闭过期京豆查询");
EnableOverBean=false
}
let EnableCheckEcard=true;
DisableIndex=strDisableList.findIndex((item) => item === "E卡查询");
if(DisableIndex!=-1){
console.log("检测到设定关闭E卡查询");
EnableCheckEcard=false
}
!(async() => {
if (!cookiesArr[intcheckckseq]) {
$.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {
"open-url": "https://bean.m.jd.com/bean/signIndex.action"
});
return;
}
i = intcheckckseq;
if (cookiesArr[i]) {
cookie = cookiesArr[i];
$.pt_pin = (cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]);
$.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]);
$.CryptoJS = $.isNode() ? require('crypto-js') : CryptoJS;
$.index = i + 1;
$.beanCount = 0;
$.incomeBean = 0;
$.expenseBean = 0;
$.todayIncomeBean = 0;
$.todayOutcomeBean = 0;
$.errorMsg = '';
$.isLogin = true;
$.nickName = '';
$.levelName = '';
$.message = '';
$.balance = 0;
$.expiredBalance = 0;
$.JdFarmProdName = '';
$.JdtreeEnergy = 0;
$.JdtreeTotalEnergy = 0;
$.treeState = 0;
$.JdwaterTotalT = 0;
$.JdwaterD = 0;
$.JDwaterEveryDayT = 0;
$.JDtotalcash = 0;
$.jdCash = 0;
$.isPlusVip = false;
$.isRealNameAuth=false;
$.JingXiang = "";
$.allincomeBean = 0; //月收入
$.allexpenseBean = 0; //月支出
$.beanChangeXi = 0;
$.inJxBean = 0;
$.OutJxBean = 0;
$.todayinJxBean = 0;
$.todayOutJxBean = 0;
$.xibeanCount = 0;
$.YunFeiTitle = "";
$.YunFeiQuan = 0;
$.YunFeiQuanEndTime = "";
$.YunFeiTitle2 = "";
$.YunFeiQuan2 = 0;
$.YunFeiQuanEndTime2 = "";
$.ECardinfo = "";
$.PlustotalScore=0;
$.marketCardTotal="";
TempBaipiao = "";
strGuoqi = "";
await TotalBean();
if (!$.isLogin) {
await isLoginByX1a0He();
}
if (!$.isLogin) {
console.log(`【提示】cookie已失效,\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`);
return
}
if ($.beanCount == 0) {
console.log("疑似获取失败,用第二个接口试试....")
var userdata = await getuserinfo();
if (userdata.code == 1) {
$.beanCount = userdata.content.jdBean;
}
}
await Promise.all([
getjdfruitinfo(), //东东农场
cash(), //极速金币
bean(), //京豆查询
jdCash(), //领现金
GetJxBeaninfo(), //喜豆查询
CheckEcard(), //E卡查询
getmarketCard()
])
await showMsg();
}
})()
.catch((e) => {
$.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '')
})
.finally(() => {
$.done();
})
async function showMsg() {
//if ($.errorMsg)
//return
ReturnMessageTitle="";
ReturnMessage = "";
var strsummary="";
var temptest = await getEnvByPtPin($.UserName);
var strRemark=getRemark(temptest.remarks);
if(strRemark)
ReturnMessageTitle = `【账号🆔${(intcheckckseq+1)}】`+strRemark;
else
ReturnMessageTitle = `【账号${(intcheckckseq+1)}收支情况】`;
if ($.JingXiang) {
if ($.isRealNameAuth)
ReturnMessageTitle += `(已实名)\n`;
else
ReturnMessageTitle += `(未实名)\n`;
ReturnMessage += `【账号信息】`;
if ($.isPlusVip) {
ReturnMessage += `Plus会员`;
if ($.PlustotalScore)
ReturnMessage += `(${$.PlustotalScore}分)`
} else {
ReturnMessage += `普通会员`;
}
ReturnMessage += `,京享值${$.JingXiang}\n`;
}else{
ReturnMessageTitle+= `\n`;
}
ReturnMessage += `【今日京豆】收${$.todayIncomeBean}豆`;
strsummary+= `【今日京豆】收${$.todayIncomeBean}豆`;
if ($.todayOutcomeBean != 0) {
ReturnMessage += `,支${$.todayOutcomeBean}豆`;
strsummary += `,支${$.todayOutcomeBean}豆`;
}
ReturnMessage += `\n`;
strsummary+= `\n`;
ReturnMessage += `【昨日京豆】收${$.incomeBean}豆`;
if ($.expenseBean != 0) {
ReturnMessage += `,支${$.expenseBean}豆`;
}
ReturnMessage += `\n`;
if ($.beanCount){
ReturnMessage += `【当前京豆】${$.beanCount-$.beanChangeXi}豆(≈${(($.beanCount-$.beanChangeXi)/ 100).toFixed(2)}元)\n`;
strsummary+= `【当前京豆】${$.beanCount-$.beanChangeXi}豆(≈${(($.beanCount-$.beanChangeXi)/ 100).toFixed(2)}元)\n`;
} else {
if($.levelName || $.JingXiang)
ReturnMessage += `【当前京豆】获取失败,接口返回空数据\n`;
else{
ReturnMessage += `【当前京豆】${$.beanCount-$.beanChangeXi}豆(≈${(($.beanCount-$.beanChangeXi)/ 100).toFixed(2)}元)\n`;
strsummary += `【当前京豆】${$.beanCount-$.beanChangeXi}豆(≈${(($.beanCount-$.beanChangeXi)/ 100).toFixed(2)}元)\n`;
}
}
if (EnableJxBeans) {
ReturnMessage += `【今日喜豆】收${$.todayinJxBean}豆`;
if ($.todayOutJxBean != 0) {
ReturnMessage += `,支${$.todayOutJxBean}豆`;
}
ReturnMessage += `\n`;
ReturnMessage += `【昨日喜豆】收${$.inJxBean}豆`;
if ($.OutJxBean != 0) {
ReturnMessage += `,支${$.OutJxBean}豆`;
}
ReturnMessage += `\n`;
ReturnMessage += `【当前喜豆】${$.xibeanCount}喜豆(≈${($.xibeanCount/ 100).toFixed(2)}元)\n`;
strsummary += `【当前喜豆】${$.xibeanCount}豆(≈${($.xibeanCount/ 100).toFixed(2)}元)\n`;
}
if ($.JDtotalcash) {
ReturnMessage += `【特价金币】${$.JDtotalcash}币(≈${($.JDtotalcash / 10000).toFixed(2)}元)\n`;
}
if($.ECardinfo)
ReturnMessage += `【礼品卡余额】${$.ECardinfo}\n`;
if($.marketCardTotal)
ReturnMessage += `【超市卡余额】${$.marketCardTotal}\n`;
if ($.JdFarmProdName != "") {
if ($.JdtreeEnergy != 0) {
if ($.treeState === 2 || $.treeState === 3) {
ReturnMessage += `【东东农场】${$.JdFarmProdName} 可以兑换了!\n`;
TempBaipiao += `【东东农场】${$.JdFarmProdName} 可以兑换了!\n`;
allReceiveMessage += `【账号🆔】${$.JdFarmProdName} (东东农场)\n`;
} else {
if ($.JdwaterD != 'Infinity' && $.JdwaterD != '-Infinity') {
ReturnMessage += `【东东农场】${$.JdFarmProdName}(${(($.JdtreeEnergy / $.JdtreeTotalEnergy) * 100).toFixed(0)}%,${$.JdwaterD}天)\n`;
} else {
ReturnMessage += `【东东农场】${$.JdFarmProdName}(${(($.JdtreeEnergy / $.JdtreeTotalEnergy) * 100).toFixed(0)}%)\n`;
}
}
} else {
if ($.treeState === 0) {
TempBaipiao += `【东东农场】水果领取后未重新种植!\n`;
allWarnMessage += `【账号🆔】水果领取后未重新种植! (东东农场)\n`;
} else if ($.treeState === 1) {
ReturnMessage += `【东东农场】${$.JdFarmProdName}种植中...\n`;
} else {
TempBaipiao += `【东东农场】状态异常!\n`;
allWarnMessage += `【账号🆔】状态异常! (东东农场)\n`;
//ReturnMessage += `【东东农场】${$.JdFarmProdName}状态异常${$.treeState}...\n`;
}
}
}
if ($.jdCash) {
ReturnMessage += `【其他信息】`;
if ($.jdCash) {
ReturnMessage += `领现金:${$.jdCash}元`;
}
ReturnMessage += `\n`;
}
if(strGuoqi){
ReturnMessage += `💸💸💸临期京豆明细💸💸💸\n`;
ReturnMessage += `${strGuoqi}`;
}
ReturnMessage += `🧧🧧🧧红包明细🧧🧧🧧\n`;
ReturnMessage += `${$.message}`;
strsummary +=`${$.message}`;
if($.YunFeiQuan){
var strTempYF="【免运费券】"+$.YunFeiQuan+"张";
if($.YunFeiQuanEndTime)
strTempYF+="(有效期至"+$.YunFeiQuanEndTime+")";
strTempYF+="\n";
ReturnMessage +=strTempYF
strsummary +=strTempYF;
}
if($.YunFeiQuan2){
var strTempYF2="【免运费券】"+$.YunFeiQuan2+"张";
if($.YunFeiQuanEndTime2)
strTempYF+="(有效期至"+$.YunFeiQuanEndTime2+")";
strTempYF2+="\n";
ReturnMessage +=strTempYF2
strsummary +=strTempYF2;
}
allMessage += ReturnMessageTitle+ReturnMessage + `\n`;
console.log(`${ReturnMessageTitle+ReturnMessage}`);
}
async function bean() {
// console.log(`北京时间零点时间戳:${parseInt((Date.now() + 28800000) / 86400000) * 86400000 - 28800000}`);
// console.log(`北京时间2020-10-28 06:16:05::${new Date("2020/10/28 06:16:05+08:00").getTime()}`)
// 不管哪个时区。得到都是当前时刻北京时间的时间戳 new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000
//前一天的0:0:0时间戳
const tm = parseInt((Date.now() + 28800000) / 86400000) * 86400000 - 28800000 - (24 * 60 * 60 * 1000);
// 今天0:0:0时间戳
const tm1 = parseInt((Date.now() + 28800000) / 86400000) * 86400000 - 28800000;
let page = 1,
t = 0,
yesterdayArr = [],
todayArr = [];
do {
let response = await getJingBeanBalanceDetail(page);
// console.log(`第${page}页: ${JSON.stringify(response)}`);
if (response && response.code === "0") {
page++;
let detailList = response.jingDetailList;
if (detailList && detailList.length > 0) {
for (let item of detailList) {
const date = item.date.replace(/-/g, '/') + "+08:00";
if (new Date(date).getTime() >= tm1 && (!item['eventMassage'].includes("退还") && !item['eventMassage'].includes("物流") && !item['eventMassage'].includes('扣赠'))) {
todayArr.push(item);
} else if (tm <= new Date(date).getTime() && new Date(date).getTime() < tm1 && (!item['eventMassage'].includes("退还") && !item['eventMassage'].includes("物流") && !item['eventMassage'].includes('扣赠'))) {
//昨日的
yesterdayArr.push(item);
} else if (tm > new Date(date).getTime()) {
//前天的
t = 1;
break;
}
}
} else {
$.errorMsg = `数据异常`;
$.msg($.name, ``, `账号${$.index}:${$.nickName}\n${$.errorMsg}`);
t = 1;
}
} else if (response && response.code === "3") {
console.log(`cookie已过期,或者填写不规范,跳出`)
t = 1;
} else {
console.log(`未知情况:${JSON.stringify(response)}`);
console.log(`未知情况,跳出`)
t = 1;
}
} while (t === 0);
for (let item of yesterdayArr) {
if (Number(item.amount) > 0) {
$.incomeBean += Number(item.amount);
} else if (Number(item.amount) < 0) {
$.expenseBean += Number(item.amount);
}
}
for (let item of todayArr) {
if (Number(item.amount) > 0) {
$.todayIncomeBean += Number(item.amount);
} else if (Number(item.amount) < 0) {
$.todayOutcomeBean += Number(item.amount);
}
}
$.todayOutcomeBean = -$.todayOutcomeBean;
$.expenseBean = -$.expenseBean;
if(EnableOverBean)
await jingBeanDetail();//过期京豆
await redPacket();
}
async function jdCash() {
if (!EnableCash)
return;
let functionId = "cash_homePage";
let sign = `body=%7B%7D&build=167968&client=apple&clientVersion=10.4.0&d_brand=apple&d_model=iPhone13%2C3&ef=1&eid=eidI25488122a6s9Uqq6qodtQx6rgQhFlHkaE1KqvCRbzRnPZgP/93P%2BzfeY8nyrCw1FMzlQ1pE4X9JdmFEYKWdd1VxutadX0iJ6xedL%2BVBrSHCeDGV1&ep=%7B%22ciphertype%22%3A5%2C%22cipher%22%3A%7B%22screen%22%3A%22CJO3CMeyDJCy%22%2C%22osVersion%22%3A%22CJUkDK%3D%3D%22%2C%22openudid%22%3A%22CJSmCWU0DNYnYtS0DtGmCJY0YJcmDwCmYJC0DNHwZNc5ZQU2DJc3Zq%3D%3D%22%2C%22area%22%3A%22CJZpCJCmC180ENcnCv80ENc1EK%3D%3D%22%2C%22uuid%22%3A%22aQf1ZRdxb2r4ovZ1EJZhcxYlVNZSZz09%22%7D%2C%22ts%22%3A1648428189%2C%22hdid%22%3A%22JM9F1ywUPwflvMIpYPok0tt5k9kW4ArJEU3lfLhxBqw%3D%22%2C%22version%22%3A%221.0.3%22%2C%22appname%22%3A%22com.360buy.jdmobile%22%2C%22ridx%22%3A-1%7D&ext=%7B%22prstate%22%3A%220%22%2C%22pvcStu%22%3A%221%22%7D&isBackground=N&joycious=104&lang=zh_CN&networkType=3g&networklibtype=JDNetworkBaseAF&partner=apple&rfs=0000&scope=11&sign=98c0ea91318ef1313786d86d832f1d4d&st=1648428208392&sv=101&uemps=0-0&uts=0f31TVRjBSv7E8yLFU2g86XnPdLdKKyuazYDek9RnAdkKCbH50GbhlCSab3I2jwM04d75h5qDPiLMTl0I3dvlb3OFGnqX9NrfHUwDOpTEaxACTwWl6n//EOFSpqtKDhg%2BvlR1wAh0RSZ3J87iAf36Ce6nonmQvQAva7GoJM9Nbtdah0dgzXboUL2m5YqrJ1hWoxhCecLcrUWWbHTyAY3Rw%3D%3D`
return new Promise((resolve) => {
$.post(apptaskUrl(functionId, sign), async(err, resp, data) => {
try {
if (err) {
console.log(`${JSON.stringify(err)}`)
console.log(`jdCash API请求失败,请检查网路重试`)
} else {
if (safeGet(data)) {
data = JSON.parse(data);
if (data.code === 0 && data.data.result) {
$.jdCash = data.data.result.totalMoney || 0;
return
}
}
}
} catch (e) {
$.logErr(e, resp)
}
finally {
resolve(data);
}
})
})
}
function randomUserAgent() {
const uuid = generateRandomString('abcdefghijklmnopqrstuvwxyz0123456789', 40);
const addressid = generateRandomString('1234567898647', 10);
const iosVer = selectRandomFromArray(["15.1.1", "14.5.1", "14.4", "14.3", "14.2", "14.1", "14.0.1"]);
const iosV = iosVer.replace(/\./g, '_');
const clientVersion = selectRandomFromArray(["10.3.0", "10.2.7", "10.2.4"]);
const iPhone = selectRandomFromArray(["8", "9", "10", "11", "12", "13"]);
const ADID = `${generateRandomString('0987654321ABCDEF', 8)}-${generateRandomString('0987654321ABCDEF', 4)}-${generateRandomString('0987654321ABCDEF', 4)}-${generateRandomString('0987654321ABCDEF', 4)}-${generateRandomString('0987654321ABCDEF', 12)}`;
const area = `${generateRandomString('0123456789', 2)}_${generateRandomString('0123456789', 4)}_${generateRandomString('0123456789', 5)}_${generateRandomString('0123456789', 4)}`;
const lng = `119.31991256596${randomInt(100, 999)}`;
const lat = `26.1187118976${randomInt(100, 999)}`;
const UserAgent = `jdapp;iPhone;10.0.4;${iosVer};${uuid};network/wifi;ADID/${ADID};model/iPhone${iPhone},1;addressid/${addressid};appBuild/167707;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS ${iosV} like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/null;supportJDSHWK/1`;
return UserAgent;
}
function generateRandomString(chars, length) {
let result = '';
for (let i = 0; i < length; i++) {
result += chars.charAt(Math.floor(Math.random() * chars.length));
}
return result;
}
function selectRandomFromArray(array) {
return array[Math.floor(Math.random() * array.length)];
}
function randomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min);
}
async function CheckEcard(ck) {
if (!EnableCheckEcard)
return;
const UA=randomUserAgent();
const url = 'https://mygiftcard.jd.com/giftcard/queryGiftCardItem/app?source=JDAP';
const headers = {
"accept": "application/json, text/plain, */*",
"accept-encoding": "gzip, deflate, br",
"accept-language": "zh-CN,zh-Hans;q=0.9",
"content-length": "44",
"content-type": "application/x-www-form-urlencoded",
"cookie": cookie,
"origin": "https://mygiftcard.jd.com",
"referer": "https://mygiftcard.jd.com/giftcardForM.html?source=JDAP&sid=9f55a224c8286baa2fe3a7545bbd411w&un_area=16_1303_48712_48758",
"user-agent": UA
};
let balance = 0;
let TotalCard = 0;
try {
var data = 'pageNo=1&queryType=1&cardType=-1&pageSize=20';
var response = await axios.post(url, data, { headers: headers });
var couponVOList = response.data.couponVOList;
TotalCard+=couponVOList.length;
for (let i = 0; i < couponVOList.length; i++) {
balance += couponVOList[i]['balance'];
}
if (TotalCard==20){
data = 'pageNo=2&queryType=1&cardType=-1&pageSize=20';
response = await axios.post(url, data, { headers: headers });
couponVOList = response.data.couponVOList;
TotalCard+=couponVOList.length;
for (let i = 0; i < couponVOList.length; i++) {
balance += couponVOList[i]['balance'];
}
}
if (balance > 0)
$.ECardinfo = '共' + TotalCard + '张E卡,合计' + parseFloat(balance).toFixed(2) + '元';
} catch (e) {
console.error(e);
}
}
async function getmarketCard() {
const url = 'https://api.m.jd.com/atop_channel_marketCard_cardInfo';
const UA=randomUserAgent();
const headers = {
"accept": "*/*",
"accept-encoding": "gzip, deflate, br",
"accept-language": "zh-CN,zh-Hans;q=0.9",
"content-length": "1250",
"content-type": "application/x-www-form-urlencoded",
"cookie": cookie,
"origin": "https://pro.m.jd.com",
"referer": "https://pro.m.jd.com/mall/active/3KehY4eAj3D1iLzFB7p5pb68qXkT/index.html?stath=54&navh=44&topNavStyle=1&babelChannel=ttt9&hideAnchorBottomTab=1&hideBack=1&tttparams=ib0MwweyJnTGF0IjoiMjYuMTE5OTQ2IiwidW5fYXJlYSI6IjE2XzEzMDNfNDg3MTJfNDg3NTgiLCJkTGF0IjoiIiwicHJzdGF0ZSI6IjAiLCJhZGRyZXNzSWQiOiI5MjU4MDQyNTg3IiwibGF0IjoiMC4wMDAwMDAiLCJwb3NMYXQiOiIyNi4xMTk5NDYiLCJwb3NMbmciOiIxMTkuMzIwMzM5IiwiZ3BzX2FyZWEiOiIwXzBfMF8wIiwibG5nIjoiMC4wMDAwMDAiLCJ1ZW1wcyI6IjAtMC0yIiwiZ0xuZyI6IjExOS4zMjAzMzkiLCJtb2RlbCI6ImlQaG9uZTE1LDIiLCJkTG5nIjoiIn60%3D&forceCurrentView=1&showhead=no",
"request-from": "native",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-site",
"user-agent": UA,
"x-referer-page": "https://pro.m.jd.com/mall/active/3KehY4eAj3D1iLzFB7p5pb68qXkT/index.html",
"x-rp-client": "h5_1.0.0"
};
const data='appid=jd-super-market&t=1705212843271&functionId=atop_channel_marketCard_cardInfo&client=m&uuid=1201e4461b24640164a706c0a3444fd79de6577f&body=%7B%22babelChannel%22%3A%22ttt9%22%2C%22isJdApp%22%3A%221%22%2C%22isWx%22%3A%220%22%7D&h5st=20240114141403366%3Btnyqq56fhh69dd12%3B35fa0%3Btk02w847d1aac41lMXgyKzErM2w1k33PAhGy9ZX69M3Rvtgag743srkufMW1LE0zE5Crn405w3HPl20IgdET8DfgM32d%3B87c14a095a901f37feabf4d6616b8e149539de48e2fd715bedda5baea9729c41%3B4.3%3B1705212843366%3B5fb5b0eea0d604be5747ccee135178e687458f7f659003bdc2ca943d6e3006043ae4bf75ab450370c9d309909a15a988f37ccb53c9ced6e3017095a1065b75238ed637a529a266eb3370fc34ce5a9036017e96632bec64838fdb2f9b39c675cdc7d19ddc121504a7a32f7e1da54fc20c2f8ce6b879c255b77a506eb644aa4e532df91f2c44c6e7412b713f82847feb7e76668e7b0dd6e97685dfff3708e0fa5d4a08ca7a4eba27b71f0d5ecbc75cb17e6c4a6052b5b7b30d17005a24eb576981c7dd1b066a8ac01ffee3f77faa4cba708daf2be433c83204e302ac610d3eba913f78a2d39a82d2f74c9f05fee1768d97ffae5668989394f4412c7de5dd105e663aca420a85fa949e412ff869d0199814a265a0f13cad4ff8e0a4e6c3ccebbd22cb1f0398da3ef6eedb3b6941fdc55d7449823c957977e607ddbdf39a6e016f98&x-api-eid-token=jdd03NK6FVUZZ5D76SCVX2RZCJX3PGM7JVJNWMQ56NLLLQEEVURFKGHP537UFXMCBYWZUBFICVZMQJNXLODQMJOA6B3YOIAAAAAMNA2NP7SQAAAAAD5BK47RNLM7UAYX'
try {
const response = await axios.post(url, data, { headers });
if (response.data.success && response.data.data?.floorData?.items && response.data.data?.floorData?.items[0].marketCardVO.balance>0) {
$.marketCardTotal = "总"+response.data.data?.floorData?.items[0].marketCardVO.balance+"元";
if(response.data.data?.floorData?.items[0].marketCardVO.expirationGiftAmountDes)
$.marketCardTotal +=","+response.data.data?.floorData?.items[0].marketCardVO.expirationGiftAmountDes;
}
} catch (e) {
console.error(e);
}
}
function apptaskUrl(functionId = "", body = "") {
return {
url: `${JD_API_HOST}?functionId=${functionId}`,
body,
headers: {
'Cookie': cookie,
'Host': 'api.m.jd.com',
'Connection': 'keep-alive',
'Content-Type': 'application/x-www-form-urlencoded',
'Referer': '',
'User-Agent': 'JD4iPhone/167774 (iPhone; iOS 14.7.1; Scale/3.00)',
'Accept-Language': 'zh-Hans-CN;q=1',
'Accept-Encoding': 'gzip, deflate, br',
},
timeout: 10000
}
}
function TotalBean() {
return new Promise(async resolve => {
const options = {
url: "https://me-api.jd.com/user_new/info/GetJDUserInfoUnion",
headers: {
"Accept": "application/json, text/plain",
"accept-encoding": "gzip, deflate, br",
"content-type": "application/json;charset=UTF-8",
Cookie: cookie,
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36 Edg/106.0.1370.42"
},
timeout: 10000
}
$.get(options, (err, resp, data) => {
try {
if (err) {
$.logErr(err)
} else {
if (data) {
data = JSON.parse(data);
if (data['retcode'] === "1001") {
$.isLogin = false; //cookie过期
return;
}
if (data['retcode'] === "0" && data.data && data.data.hasOwnProperty("userInfo")) {
$.nickName = data.data.userInfo.baseInfo.nickname;
$.levelName = data.data.userInfo.baseInfo.levelName;
$.isPlusVip = data.data.userInfo.isPlusVip;
$.isRealNameAuth=(data.data.userInfo.isRealNameAuth==1);
}
if (data['retcode'] === '0' && data.data && data.data['assetInfo']) {
if ($.beanCount == 0)
$.beanCount = data.data && data.data['assetInfo']['beanNum'];
} else {
$.errorMsg = `数据异常`;
}
} else {
$.log('京东服务器返回空数据,将无法获取等级及VIP信息');
}
}
} catch (e) {
$.logErr(e)
}
finally {
resolve();
}
})
})
}
async function getuserinfo() {
var body=[{"pin": "$cooMrdGatewayUid$"}];
var ua = `jdapp;iPhone;${random(["11.1.0", "10.5.0", "10.3.6"])};${random(["13.5", "14.0", "15.0"])};${uuidRandom()};network/wifi;supportApplePay/0;hasUPPay/0;hasOCPay/0;model/iPhone11,6;addressid/7565095847;supportBestPay/0;appBuild/167541;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`;
let config = {
url: 'https://lop-proxy.jd.com/JingIntegralApi/userAccount',
body: JSON.stringify(body),
headers: {
"host": "lop-proxy.jd.com",
"jexpress-report-time": Date.now().toString(),
"access": "H5",
"source-client": "2",
"accept": "application/json, text/plain, */*",
"d_model": "iPhone11,6",
"accept-encoding": "gzip",
"lop-dn": "jingcai.jd.com",
"user-agent": ua,
"partner": "",
"screen": "375*812",
"cookie": cookie,
"x-requested-with": "XMLHttpRequest",
"version": "1.0.0",
"uuid": randomNumber(10),
"clientinfo": "{\"appName\":\"jingcai\",\"client\":\"m\"}",
"d_brand": "iPhone",
"appparams": "{\"appid\":158,\"ticket_type\":\"m\"}",
"sdkversion": "1.0.7",
"area": area(),
"client": "iOS",
"referer": "https://jingcai-h5.jd.com/",
"eid": "",
"osversion": random(["13.5", "14.0", "15.0"]),
"networktype": "wifi",
"jexpress-trace-id": uuid(),
"origin": "https://jingcai-h5.jd.com",
"app-key": "jexpress",
"event-id": uuid(),
"clientversion": random(["11.1.0", "10.5.0", "10.3.6"]),
"content-type": "application/json;charset=utf-8",
"build": "167541",
"biz-type": "service-monitor",
"forcebot": "0"
}
}
return new Promise(resolve => {
$.post(config, async(err, resp, data) => {
try {
//console.log(data)
if (err) {
console.log(err)
} else {
data = JSON.parse(data);
}
} catch (e) {
$.logErr(e, resp)
}
finally {
resolve(data || '');
}
})
})
}
function isLoginByX1a0He() {
return new Promise((resolve) => {
const options = {
url: 'https://plogin.m.jd.com/cgi-bin/ml/islogin',
headers: {
"Cookie": cookie,
"referer": "https://h5.m.jd.com/",
"User-Agent": "jdapp;iPhone;10.1.2;15.0;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
},
timeout: 10000
}
$.get(options, (err, resp, data) => {
try {
if (data) {
data = JSON.parse(data);
if (data.islogin === "1") {
console.log(`使用X1a0He写的接口加强检测: Cookie有效\n`)
} else if (data.islogin === "0") {
$.isLogin = false;
console.log(`使用X1a0He写的接口加强检测: Cookie无效\n`)
} else {
console.log(`使用X1a0He写的接口加强检测: 未知返回,不作变更...\n`)
$.error = `${$.nickName} :` + `使用X1a0He写的接口加强检测: 未知返回...\n`
}
}
} catch (e) {
console.log(e);
}
finally {
resolve();
}
});
});
}
function getJingBeanBalanceDetail(page) {
return new Promise(async resolve => {
const options = {
"url": `https://bean.m.jd.com/beanDetail/detail.json?page=${page}`,
"body": `body=${escape(JSON.stringify({"pageSize": "20", "page": page.toString()}))}&appid=ld`,
"headers": {
'User-Agent': "Mozilla/5.0 (Linux; Android 12; SM-G9880) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Mobile Safari/537.36 EdgA/106.0.1370.47",
'Content-Type': 'application/x-www-form-urlencoded',
'Cookie': cookie,
}
}
$.post(options, (err, resp, data) => {
try {
if (err) {
// console.log(`${JSON.stringify(err)}`)
// console.log(`${$.name} API请求失败,请检查网路重试`)
} else {
if (data) {
data = JSON.parse(data);
// console.log(data)
} else {
// console.log(`京东服务器返回空数据`)
}
}
} catch (e) {
// $.logErr(e, resp)
} finally {
resolve(data);
}
})
})
}
function jingBeanDetail() {
return new Promise(async resolve => {
setTimeout(async () => {
const strsign = await getSignfromNolan('jingBeanDetail', {"pageSize": "20", "page": "1"});
const options = {
"url": `https://api.m.jd.com/client.action?functionId=jingBeanDetail`,
"body": strsign,
"headers": {
'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"),
'Host': 'api.m.jd.com',
'Content-Type': 'application/x-www-form-urlencoded',
'Cookie': cookie,
}
}
$.post(options, (err, resp, data) => {
try {
if (err) {
console.log(`${JSON.stringify(err)}`)
console.log(`${$.name} getJingBeanBalanceDetail API请求失败,请检查网路重试`)
} else {
if (data) {
data = JSON.parse(data);
if (data?.others?.jingBeanExpiringInfo?.detailList) {
const { detailList = [] } = data?.others?.jingBeanExpiringInfo;
detailList.map(item => {
strGuoqi+=`【${(item['eventMassage']).replace("即将过期京豆","").replace("年","-").replace("月","-").replace("日","")}】过期${item['amount']}豆\n`;
})
}
} else {
console.log(`jingBeanDetail 京东服务器返回空数据`)
}
}
} catch (e) {
$.logErr(e, resp)
} finally {
resolve(data);
}
})
}, 0 * 1000);
})
}
function getSignfromNolan(functionId, body) {
var strsign = '';
let data = {
"fn":functionId,
"body": body
}
return new Promise((resolve) => {
let url = {
url: jdSignUrl,
body: JSON.stringify(data),
followRedirect: false,
headers: {
'Accept': '*/*',
"accept-encoding": "gzip, deflate, br",
'Content-Type': 'application/json'
},
timeout: 30000
}
$.post(url, async(err, resp, data) => {
try {
data = JSON.parse(data);
if (data && data.body) {
if (data.body)
strsign = data.body || '';
if (strsign != '')
resolve(strsign);
else
console.log("签名获取失败.");
} else {
console.log("签名获取失败.");
}
}catch (e) {
$.logErr(e, resp);
}finally {
resolve(strsign);
}
})
})
}
function redPacket() {
return new Promise(async resolve => {
const options = {
"url": `https://api.m.jd.com/client.action?functionId=myhongbao_getUsableHongBaoList&body=%7B%22appId%22%3A%22appHongBao%22%2C%22appToken%22%3A%22apphongbao_token%22%2C%22platformId%22%3A%22appHongBao%22%2C%22platformToken%22%3A%22apphongbao_token%22%2C%22platform%22%3A%221%22%2C%22orgType%22%3A%222%22%2C%22country%22%3A%22cn%22%2C%22childActivityId%22%3A%22-1%22%2C%22childActiveName%22%3A%22-1%22%2C%22childActivityTime%22%3A%22-1%22%2C%22childActivityUrl%22%3A%22-1%22%2C%22openId%22%3A%22-1%22%2C%22activityArea%22%3A%22-1%22%2C%22applicantErp%22%3A%22-1%22%2C%22eid%22%3A%22-1%22%2C%22fp%22%3A%22-1%22%2C%22shshshfp%22%3A%22-1%22%2C%22shshshfpa%22%3A%22-1%22%2C%22shshshfpb%22%3A%22-1%22%2C%22jda%22%3A%22-1%22%2C%22activityType%22%3A%221%22%2C%22isRvc%22%3A%22-1%22%2C%22pageClickKey%22%3A%22-1%22%2C%22extend%22%3A%22-1%22%2C%22organization%22%3A%22JD%22%7D&appid=JDReactMyRedEnvelope&client=apple&clientVersion=7.0.0`,
"headers": {
'Host': 'api.m.jd.com',
'Accept': '*/*',
'Connection': 'keep-alive',
'Accept-Language': 'zh-cn',
'Referer': 'https://h5.m.jd.com/',
'Accept-Encoding': 'gzip, deflate, br',
"Cookie": cookie,
'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1")
}
}
$.get(options, (err, resp, data) => {
try {
if (err) {
console.log(`${JSON.stringify(err)}`)
console.log(`redPacket API请求失败,请检查网路重试`)
} else {
if (data) {
data = JSON.parse(data);
$.jxRed = 0,
$.jsRed = 0,
$.jdRed = 0,
$.jdhRed = 0,
$.jdwxRed = 0,
$.jdGeneralRed = 0,
$.jxRedExpire = 0,
$.jsRedExpire = 0,
$.jdRedExpire = 0,
$.jdhRedExpire = 0;
$.jdwxRedExpire = 0,
$.jdGeneralRedExpire = 0
let t = new Date();
t.setDate(t.getDate() + 1);
t.setHours(0, 0, 0, 0);
t = parseInt((t - 1) / 1000)*1000;
for (let vo of data.hongBaoList || []) {
if (vo.orgLimitStr) {
if (vo.orgLimitStr.includes("京喜") && !vo.orgLimitStr.includes("特价")) {
$.jxRed += parseFloat(vo.balance)
if (vo['endTime'] === t) {
$.jxRedExpire += parseFloat(vo.balance)
}
continue;
} else if (vo.orgLimitStr.includes("购物小程序")) {
$.jdwxRed += parseFloat(vo.balance)
if (vo['endTime'] === t) {
$.jdwxRedExpire += parseFloat(vo.balance)
}
continue;
} else if (vo.orgLimitStr.includes("京东商城")) {
$.jdRed += parseFloat(vo.balance)
if (vo['endTime'] === t) {
$.jdRedExpire += parseFloat(vo.balance)
}
continue;
} else if (vo.orgLimitStr.includes("极速") || vo.orgLimitStr.includes("京东特价") || vo.orgLimitStr.includes("京喜特价")) {
$.jsRed += parseFloat(vo.balance)
if (vo['endTime'] === t) {
$.jsRedExpire += parseFloat(vo.balance)
}
continue;
} else if (vo.orgLimitStr && vo.orgLimitStr.includes("京东健康")) {
$.jdhRed += parseFloat(vo.balance)
if (vo['endTime'] === t) {
$.jdhRedExpire += parseFloat(vo.balance)
}
continue;
}
}
$.jdGeneralRed += parseFloat(vo.balance)
if (vo['endTime'] === t) {
$.jdGeneralRedExpire += parseFloat(vo.balance)
}
}
$.balance = ($.jxRed+$.jsRed+$.jdRed +$.jdhRed+$.jdwxRed+$.jdGeneralRed).toFixed(2);
$.jxRed = $.jxRed.toFixed(2);
$.jsRed = $.jsRed.toFixed(2);
$.jdRed = $.jdRed.toFixed(2);
$.jdhRed = $.jdhRed.toFixed(2);
$.jdwxRed = $.jdwxRed.toFixed(2);
$.jdGeneralRed = $.jdGeneralRed.toFixed(2);
$.expiredBalance = ($.jxRedExpire + $.jsRedExpire + $.jdRedExpire+$.jdhRedExpire+$.jdwxRedExpire+$.jdGeneralRedExpire).toFixed(2);
$.message += `【红包总额】${$.balance}(总过期${$.expiredBalance})元 \n`;
if ($.jxRed > 0){
if($.jxRedExpire>0)
$.message += `【京喜红包】${$.jxRed}(将过期${$.jxRedExpire.toFixed(2)})元 \n`;
else
$.message += `【京喜红包】${$.jxRed}元 \n`;
}
if ($.jsRed > 0){
if($.jsRedExpire>0)
$.message += `【京喜特价】${$.jsRed}(将过期${$.jsRedExpire.toFixed(2)})元(原极速版) \n`;
else
$.message += `【京喜特价】${$.jsRed}元(原极速版) \n`;
}
if ($.jdRed > 0){
if($.jdRedExpire>0)
$.message += `【京东红包】${$.jdRed}(将过期${$.jdRedExpire.toFixed(2)})元 \n`;
else
$.message += `【京东红包】${$.jdRed}元 \n`;
}
if ($.jdhRed > 0){
if($.jdhRedExpire>0)
$.message += `【健康红包】${$.jdhRed}(将过期${$.jdhRedExpire.toFixed(2)})元 \n`;
else
$.message += `【健康红包】${$.jdhRed}元 \n`;
}
if ($.jdwxRed > 0){
if($.jdwxRedExpire>0)
$.message += `【微信小程序】${$.jdwxRed}(将过期${$.jdwxRedExpire.toFixed(2)})元 \n`;
else
$.message += `【微信小程序】${$.jdwxRed}元 \n`;
}
if ($.jdGeneralRed > 0){
if($.jdGeneralRedExpire>0)
$.message += `【全平台通用】${$.jdGeneralRed}(将过期${$.jdGeneralRedExpire.toFixed(2)})元 \n`;
else
$.message += `【全平台通用】${$.jdGeneralRed}元 \n`;