-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathjd_lzkj_loreal_share.js
952 lines (947 loc) · 45.2 KB
/
jd_lzkj_loreal_share.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
/**
活动名称:分享有礼(超级无线欧莱雅)
活动链接:https://lzkj-isv.isvjcloud.com/prod/cc/interactsaas/index?activityType=<10043>&templateId=<模板id>&activityId=<活动id>&nodeId=<nodeid>&prd=cjwx
支持activityType :(10043)
环境变量:
jd_lzkj_loreal_share_url // 活动链接
jd_lzkj_loreal_share_helpnum // 账号数 默认助力前3账号,需要助力其他请自行设置变量
请使用本地IP环境 请使用本地IP环境 请使用本地IP环境
cron:1 1 1 1 *
============Quantumultx===============
[task_local]
#lzkj_loreal分享有礼
1 1 1 1 * jd_lzkj_loreal_share.js, tag=lzkj_loreal分享有礼, enabled=true
*/
if (process.env.proxy_wind === 'true') {const setGlobalHttpProxy = require('./utils/proxy-wind.js');setGlobalHttpProxy();}
let lnrun = 0;
const $ = new Env("分享有礼(lzkj_loreal)");
const iiii1 = $.isNode() ? require("./sendNotify") : "",
l1li1I = $.isNode() ? require("./jdCookie.js") : "",
iIlli1 = require("./function/krgetToken"),
I1IIIl = require("./function/krh5st"),
il1IlI = require("./function/krgetua");
let I1IIIi = {},
lI11 = process.env.jd_lzkj_loreal_share_url,
li11I1 = 3;
process.env.jd_lzkj_loreal_share_helpnum && process.env.jd_lzkj_loreal_share_helpnum != "" && (li11I1 = process.env.jd_lzkj_loreal_share_helpnum);
let i1I111 = [],
l1li11 = [],
il1Il1 = [],
li11II = true,
Ii1li = null,
iIiIli = "";
$.activityEnd = false;
let i1I11I = [],
Ii1lli = "",
Ii1lll = "";
if ($.isNode()) {
if (process.env.jd_lzkj_loreal_share_url) lI11 = process.env.jd_lzkj_loreal_share_url;
if (JSON.stringify(process.env).indexOf("GITHUB") > -1) process.exit(0);
Object.keys(l1li1I).forEach(iIlii => {
i1I11I.push(l1li1I[iIlii]);
});
if (process.env.JD_DEBUG && process.env.JD_DEBUG === "false") console.log = () => {};
} else i1I11I = [$.getdata("CookieJD"), $.getdata("CookieJD2"), ...$.toObj($.getdata("CookiesJD") || "[]").map(lI1I => lI1I.cookie)].filter(I1Ii => !!I1Ii);
let I1I1 = typeof $request !== "undefined";
I1I1 && (GetCookie(), $.done());
if (lI11) {
Ii1li = liII1I("" + lI11, "activityId");
activityType = liII1I("" + lI11, "activityType");
templateId = liII1I("" + lI11, "templateId");
if (lI11.includes("lorealjdcampaign-rc")) wxActType = "apps/interact";else lI11.includes("lzkj") ? wxActType = lI11.match(/\/(prod\/cc\/interact\w*)\//)[1] : console.log("暂不支持的类型");
$.domain = lI11.match(/https?:\/\/([^/]+)/)[1];
}
let Ii1lI = "https://" + $.domain;
!(async () => {
if (Ii1li == null) {
console.log("活动id不存在");
return;
}
console.log("活动入口:" + lI11);
if (!i1I11I[0]) {
$.msg($.name, "【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取", "https://bean.m.jd.com/", {
"open-url": "https://bean.m.jd.com/"
});
return;
}
process.env.jd_lzkj_loreal_address ? UserAdd_Data_Arr = process.env.jd_lzkj_loreal_address : UserAdd_Data_Arr = process.env.WX_ADDRESS ? process.env.WX_ADDRESS : "";
if (UserAdd_Data_Arr && UserAdd_Data_Arr != "") {
let I1IIi = [];
I1IIi = UserAdd_Data_Arr.split("|");
var il1Ill = Math.floor(Math.random() * I1IIi.length);
if (I1IIi[il1Ill] == "") {
console.log("随机抽取到的收货地址信息为空,请正确使用 \"|\" 管道符以用于分割多个收货地址!");
return;
} else I1IIi = I1IIi[il1Ill];
if (process.env.jd_lzkj_loreal_address) {
I1IIi = I1IIi.split("@");
if (I1IIi.length != 6) {
console.log("随机抽取到的收货地址信息格式存在错误(参数不足或过多)");
return;
}
for (let iiii1I = 0; iiii1I < 6; iiii1I++) {
if (I1IIi[iiii1I] == "") {
console.log("随机抽取到的收货地址信息格式存在错误(参数不能为空)");
return;
}
}
} else {
I1IIi = I1IIi.split("@");
if (I1IIi.length != 8) {
console.log("随机抽取到的收货地址信息格式存在错误(参数不足或过多)");
return;
}
for (let l1II1l = 0; l1II1l < 7; l1II1l++) {
if (I1IIi[l1II1l] == "") {
console.log("随机抽取到的收货地址信息格式存在错误(参数不能为空)");
return;
}
}
}
$.receiver = I1IIi[0];
$.phone = I1IIi[1];
$.province = I1IIi[2];
$.city = I1IIi[3];
$.county = I1IIi[4];
$.address = I1IIi[5];
}
console.log("\n开始收集助力码中...");
li11II = true;
$.maxShareTimes = 0;
$.prizeNameout = false;
for (let i1IIlI = 0; i1IIlI < li11I1; i1IIlI++) {
if (i1I11I[i1IIlI]) {
Ii1lli = i1I11I[i1IIlI];
originCookie = i1I11I[i1IIlI];
$.UserName = decodeURIComponent(Ii1lli.match(/pt_pin=(.+?);/) && Ii1lli.match(/pt_pin=(.+?);/)[1]);
$.index = i1IIlI + 1;
$.isLogin = true;
$.nickName = "";
console.log("\n开始【京东账号" + $.index + "】" + ($.nickName || $.UserName) + "\n");
let Interval = process.env.jd_jk_interval || 60 * 1000;console.log("环境变量jd_task_interval已设置为"+Interval/1000+"秒");lnrun++;if(lnrun == 3){console.log(`\n【访问接口次数达到2次,休息一分钟.....】\n`);await $.wait(Interval);lnrun = 0}
if (!$.isLogin) {
$.msg($.name, "【提示】cookie已失效", "京东账号" + $.index + " " + ($.nickName || $.UserName) + "\n请重新登录获取\nhttps://bean.m.jd.com/", {
"open-url": "https://bean.m.jd.com/"
});
$.isNode() && (await iiii1.sendNotify($.name + "cookie已失效 - " + $.UserName, "京东账号" + $.index + " " + $.UserName + "\n请重新登录获取cookie"));
continue;
}
$.UA = await il1IlI($.UserName);
$.token = "";
$.OpenCard = false;
$.authorCode = "";
$.token = await iIlli1(Ii1lli, Ii1lI);
if ($.token == "") {
console.log("获取[token]失败!");
return;
}
if ($.token) {
await iIiIii("api/user-info/login", {
"status": "1",
"activityId": Ii1li,
"tokenPin": $.token,
"source": "01",
"shareUserId": ""
});
if ($.hasEnd || $.activityEnd || $.outFlag || $.OpenCard) return;
await $.wait(300);
await lI1i();
await iIiIii("api/user-info/login", {
"status": "1",
"activityId": Ii1li,
"tokenPin": $.token,
"source": "01",
"shareUserId": ""
});
await $.wait(300);
await i11();
if ($.hasEnd || $.activityEnd || $.outFlag) return;
await liII1l();
await $.wait(300);
if ($.index == 1) {
$.prizeList = "";
let ll1l11 = false;
for (let iIl1I1 = 0; iIl1I1 < $.prizeInfo.length; iIl1I1++) {
let il1lI1 = false;
$.prizeName = $.prizeInfo[iIl1I1].prizeName;
$.leftNum = $.prizeInfo[iIl1I1].leftNum;
$.leftNum <= 0 ? $.prizeNum = "(已发完)" : $.prizeNum = "";
$.prizeType = $.prizeInfo[iIl1I1].prizeType;
$.position = $.shareSuccessTimesList[iIl1I1].successTimes || 9999;
let i111li = $.shareSuccessTimesList[iIl1I1].prizeInfoId || "",
lIlIiI = $.shareSuccessTimesList[iIl1I1].status || 0;
switch ($.prizeType) {
case 1:
$.prizeType = "[京豆]";
break;
case 2:
$.prizeType = "[优惠券]";
break;
case 3:
$.prizeType = "[实物]";
break;
case 4:
$.prizeType = "[积分]";
break;
case 5:
$.prizeType = "[专享价]";
break;
case 6:
$.prizeType = "[红包]";
break;
case 7:
$.prizeType = "[礼品卡]";
break;
case 8:
$.prizeType = "[E卡]";
break;
case 9:
$.prizeType = "[PLUS会员]";
break;
case 10:
$.prizeType = "[爱奇艺会员]";
break;
case 11:
$.prizeType = "[积分]";
break;
default:
console.log("未成功获取数据");
return;
}
iIl1I1 != $.prizeInfo.length - 1 ? $.prizeList += $.position + "人--" + $.prizeType + $.prizeName + "(剩余" + $.leftNum + "件)" + $.prizeNum + "\n" : $.prizeList += $.position + "人--" + $.prizeType + $.prizeName + "(剩余" + $.leftNum + "件)" + $.prizeNum + "\n";
lIlIiI != 4 && ($.prizeName.includes("券") && (ll1l11 = true, il1lI1 = true), !il1lI1 && $.position <= i1I11I.length && (l1li11.push(i111li), il1Il1.push($.position)), $.position > $.maxShareTimes && !il1lI1 && $.position <= i1I11I.length && ($.maxShareTimes = $.position));
lIlIiI == 3 && ($.prizeNameout = true);
}
console.log("店铺名称:" + $.shopName + "\n活动名称: " + $.actName + "\n活动奖品:\n" + $.prizeList);
if (ll1l11 && $.maxShareTimes == 0) {
console.log("\n奖品全是优惠券,不跑了~");
return;
} else {
if ($.maxShareTimes == 0) {
console.log("\n奖品已经全部发完了,下次早点来哟~");
return;
}
}
}
await i1I11i();
await lI1l();
console.log("\n当前已助力人数:" + $.num + " 人\n");
for (let Ilii = 0; Ilii < il1Il1.length; Ilii++) {
$.num >= il1Il1[Ilii] + 1 && (process.stdout.write("【" + $.prizeInfo[Ilii].prizeName + "】 "), await Ii1llI(l1li11[Ilii]));
}
if ($.activityEnd || $.outFlag) return;
}
}
}
if ($.prizeNameout) {
console.log("\n奖品全部都领取了,结束运行~");
return;
}
if (!i1I111.length) {
console.log("\n没有获取到助力码...");
return;
}
console.log("\n收集助力码完成,即将进行助力...");
li11II = false;
$.shareTimes = 0;
for (let Ilil = 0; Ilil < i1I11I.length; Ilil++) {
if (i1I11I[Ilil]) {
Ii1lli = i1I11I[Ilil];
originCookie = i1I11I[Ilil];
$.UserName = decodeURIComponent(Ii1lli.match(/pt_pin=(.+?);/) && Ii1lli.match(/pt_pin=(.+?);/)[1]);
$.index = Ilil + 1;
$.isLogin = true;
$.nickName = "";
console.log("\n开始【京东账号" + $.index + "】" + ($.nickName || $.UserName) + "\n");
let Interval = process.env.jd_jk_interval || 60 * 1000;console.log("环境变量jd_task_interval已设置为"+Interval/1000+"秒");lnrun++;if(lnrun == 3){console.log(`\n【访问接口次数达到2次,休息一分钟.....】\n`);await $.wait(Interval);lnrun = 0}
if (!$.isLogin) {
$.msg($.name, "【提示】cookie已失效", "京东账号" + $.index + " " + ($.nickName || $.UserName) + "\n请重新登录获取\nhttps://bean.m.jd.com/", {
"open-url": "https://bean.m.jd.com/"
});
$.isNode() && (await iiii1.sendNotify($.name + "cookie已失效 - " + $.UserName, "京东账号" + $.index + " " + $.UserName + "\n请重新登录获取cookie"));
continue;
}
$.UA = await il1IlI($.UserName);
$.token = "";
$.OpenCard = false;
$.token = await iIlli1(Ii1lli, Ii1lI);
if ($.token) {
await iIiIii("api/user-info/login", {
"status": "1",
"activityId": Ii1li,
"tokenPin": $.token,
"source": "01",
"shareUserId": ""
});
if ($.hasEnd || $.activityEnd || $.outFlag || $.OpenCard) return;
$.maxShareTimes > 5 ? await $.wait(500) : await $.wait(200);
$.helpResult = false;
for (let iiliIl = 0; iiliIl < i1I111.length; iiliIl++) {
$.authorCode = i1I111[iiliIl];
for (let IiIl1I = 0; IiIl1I < 1; IiIl1I++) {
await i11();
$.maxShareTimes > 5 ? await $.wait(500) : await $.wait(200);
if ($.helpResult) {
console.log("已助力 ➜ " + $.authorCode);
break;
}
}
}
if ($.helpResult) $.shareTimes += 1;
for (let ii11l1 = 0; ii11l1 < il1Il1.length; ii11l1++) {
if ($.shareTimes == il1Il1[ii11l1] + 1) await iIiIlI(l1li11[ii11l1]);else continue;
}
if ($.shareTimes >= $.maxShareTimes + 1) break;
if ($.activityEnd || $.outFlag) return;
} else console.log("【京东账号" + $.index + "】 未能获取活动信息");
}
}
})().catch(i111lI => {
$.log("", " " + $.name + ", 失败! 原因: " + i111lI + "!", "");
}).finally(() => {
$.done();
});
async function iIiIlI(ii11lI) {
console.log("\n✅ 助力已达标,开始领取奖品");
lII1i1: for (let lIl11l = 0; lIl11l < li11I1; lIl11l++) {
if (i1I11I[lIl11l]) {
Ii1lli = i1I11I[lIl11l];
originCookie = i1I11I[lIl11l];
$.UserName = decodeURIComponent(Ii1lli.match(/pt_pin=(.+?);/) && Ii1lli.match(/pt_pin=(.+?);/)[1]);
$.index = lIl11l + 1;
$.isLogin = true;
$.nickName = "";
$.authorCode = "";
$.token = "";
$.OpenCard = false;
$.authorCode = "";
$.token = await iIlli1(Ii1lli, Ii1lI);
if ($.token) {
await iIiIii("api/user-info/login", {
"status": "1",
"activityId": Ii1li,
"tokenPin": $.token,
"source": "01",
"shareUserId": ""
});
if ($.hasEnd || $.activityEnd || $.outFlag || $.OpenCard) return;
await $.wait(300);
await i11();
for (let iiii1i = 0; iiii1i < $.shareSuccessTimesList.length; iiii1i++) {
if ($.shareSuccessTimesList[iiii1i].prizeInfoId != ii11lI) continue;
process.stdout.write("【" + $.UserName + "】");
if ($.shareSuccessTimesList[iiii1i].status == 1) {
await Ii1llI(ii11lI);
await $.wait(500);
} else {
if ($.shareSuccessTimesList[iiii1i].status == 3) console.log("已经领过了,不要太贪心哦~");else {
if ($.shareSuccessTimesList[iiii1i].status == 4) {
console.log("很遗憾,奖品 " + $.shareSuccessTimesList[iiii1i].name + " 已经发完了,下次早点来吧~");
break lII1i1;
} else {
if ($.shareSuccessTimesList[iiii1i].status == 5) console.log("未中奖");else break;
}
}
}
}
} else {
$.log("没有成功获取到用户信息,跳过领取奖品");
}
}
}
}
function liII1i(iIilIi) {
let iIilIl = {
"url": "https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=" + encodeURIComponent(JSON.stringify(iIilIi)) + "&client=H5&clientVersion=9.2.0&uuid=88888&h5st=20220412164645241%3B3634d1aeada6d9cd11a7526a3a6ac63e%3B169f1%3Btk02wd66f1d7418nXuLjsmO3oJMCxUqKVwIf4q1WRptKRT3nJSrx01oYYBAylbSuyg4sipnEzyEJOZuFjfG2QERcBtzd%3B6b455234e93be4ec963cd7c575d70882b838ba588149a1f54b69c8d0dacf14da%3B3.0%3B1649753205241",
"headers": {
"Host": "api.m.jd.com",
"Accept": "*/*",
"Connection": "keep-alive",
"Cookie": Ii1lli,
"User-Agent": $.UA,
"Referer": "https://shopmember.m.jd.com/shopcard/?venderId=" + $.joinVenderId + "&channel=801&returnUrl=" + encodeURIComponent(lI11),
"Accept-Encoding": "gzip, deflate, br"
}
};
return new Promise(i111il => {
$.get(iIilIl, (lIlI1, lIllI1, Ill1) => {
try {
lIlI1 ? lIlI1 === "Response code 403 (Forbidden)" && ($.err = true, console.log(lIlI1)) : (res = JSON.parse(Ill1), res.success && ($.openCardStatus = res.result.userInfo.openCardStatus, res.result.interestsRuleList && ($.openCardActivityId = res.result.interestsRuleList[0].interestsInfo.activityId)));
} catch (iI1II) {
console.log(iI1II);
} finally {
i111il();
}
});
});
}
function iIiIil() {
return new Promise(IIilIl => {
$.msg($.name, "", "【京东账号" + $.index + "】" + $.nickName + "\n" + Ii1lll);
IIilIl();
});
}
function iIiIii(IIilIi, l1Iiii) {
return new Promise(iI1i1 => {
$.post(I1III1(IIilIi, l1Iiii), async (iiIIiI, i1liII, ilII1i) => {
try {
if (iiIIiI) {
console.log("" + JSON.stringify(iiIIiI));
console.log($.name + " login API请求失败,请检查网路重试");
} else {
ilII1i = JSON.parse(ilII1i);
if (ilII1i && ilII1i.data) {
$.tokens = ilII1i.data.token;
$.customerId = ilII1i.data.customerId;
$.joinVenderId = ilII1i.data.joinInfo.shopId;
$.openCardUrl = ilII1i.data.joinInfo.openCardUrl;
$.shopName = ilII1i.data.shopName;
$.actName = ilII1i.data.actName;
$.openCardUrl && ($.joinVenderId = ilII1i.data.joinInfo.openCardUrl.match(/venderId=(\d+)/)[1]);
$.joinDes = ilII1i.data.joinInfo.joinCodeInfo.joinDes;
if ($.joinDes.indexOf("不是会员") > -1 || $.joinDes.indexOf("加入会员") > -1) {
$.errorJoinShop = "";
await IIlIlI();
for (let ilII1l = 0; ilII1l < Array(2).length; ilII1l++) {
if (ilII1l > 0) console.log("第" + ilII1l + "次 重新开卡");
await Ii1ll1();
if ($.errorJoinShop.indexOf("活动太火爆,请稍后再试") == -1 && $.errorJoinShop.indexOf("加入店铺会员失败") == -1) break;
$.errorJoinShop.indexOf("活动太火爆,请稍后再试") > -1 && (console.log("开卡失败❌ ,重新执行脚本"), $.OpenCard = true);
}
}
} else console.log(ilII1i);
i1liII.status == 200 && iIll1(i1liII);
}
} catch (l1Iil1) {
$.logErr(l1Iil1, i1liII);
} finally {
iI1i1();
}
});
});
}
function lI1i() {
return new Promise(lIlIii => {
let I11lil = {};
$.post(I1III1("api/task/followShop/follow", I11lil), async (l1Iill, iiiiIi, iiiiIl) => {
try {
if (l1Iill) {
console.log("" + JSON.stringify(l1Iill));
console.log($.name + " follow API请求失败,请检查网路重试");
} else {
iiiiIl = JSON.parse(iiiiIl);
if (iiiiIl && iiiiIl.resp_code == 0) {} else {
console.log(iiiiIl.resp_msg);
for (let IIi11i of ["未开始", "结束", "不存在", "不在"]) {
if (iiiiIl.resp_msg.includes(IIi11i)) {
$.activityEnd = true;
break;
}
}
}
iiiiIi.status == 200 && iIll1(iiiiIi);
}
} catch (lIIII) {
$.logErr(lIIII, iiiiIi);
} finally {
lIlIii();
}
});
});
}
function i11() {
return new Promise(I1li1i => {
let Ii11II = {
"shareUserId": $.authorCode
};
$.post(I1III1("api/task/sharePolitely/activity", Ii11II), async (lIII, iI11, liIii1) => {
try {
if (lIII) {
console.log("" + JSON.stringify(lIII));
console.log($.name + " activity API请求失败,请检查网路重试");
} else {
liIii1 = JSON.parse(liIii1);
if (liIii1 && liIii1.resp_code == 0) {
$.activitystatus = liIii1?.["data"]?.["status"] || 0;
$.shareSuccessTimesList = liIii1?.["data"]?.["shareSuccessTimesList"] || [];
$.activitystatus == 0 ? $.helpResult = true : console.log("没有助力次数或已助力过或已经助力其他人");
} else {
console.log(liIii1.resp_msg);
for (let lIl11 of ["未开始", "结束", "不存在", "不在"]) {
if (liIii1.resp_msg.includes(lIl11)) {
$.activityEnd = true;
break;
}
}
}
iI11.status == 200 && iIll1(iI11);
}
} catch (iIlIil) {
$.logErr(iIlIil, iI11);
} finally {
I1li1i();
}
});
});
}
function Ii1llI(Il1l1i) {
return new Promise(lIl1I1 => {
let iIl = {
"prizeInfoId": Il1l1i
};
$.post(I1III1("api/prize/receive/acquire", iIl), async (lIIi, l11Ili, iiill) => {
try {
if (lIIi) {
console.log("" + JSON.stringify(lIIi));
console.log($.name + " acquire API请求失败,请检查网路重试");
} else {
iiill = JSON.parse(iiill);
if (iiill && iiill.resp_code == 0) {
if (iiill.data === "") console.log("💨 空气");else {
if (iiill.data === "1") console.log("积分不足,无法抽奖");else {
drawInfo = iiill.data;
if (drawInfo) switch (drawInfo.prizeType) {
case 1:
console.log("🎉 " + drawInfo.prizeName + " 🐶");
break;
case 3:
generateId = iiill.data.prizeInfoId;
prizeName = drawInfo.prizeName;
addressId = drawInfo.addressId;
console.log("🎉 恭喜获得实物~");
console.log("奖品名称:" + prizeName);
process.env.jd_lzkj_loreal_address && (await i1I11l(addressId), await $.wait(4000));
break;
case 4:
case 11:
console.log("🎉 " + drawInfo.prizeName + " 🎟️");
break;
case 2:
console.log("🎉 " + drawInfo.prizeName + " 优惠券");
break;
case 8:
console.log("🎉 恭喜获得" + drawInfo.prizeName + " 🎁");
break;
default:
console.log(iiill.data);
break;
}
}
}
} else {
if (iiill && iiill.resp_code == 60002) console.log(iiill.resp_msg);else {
console.log(iiill);
for (let l11iI of ["未开始", "结束", "不存在", "不在"]) {
if (iiill.resp_msg.includes(l11iI)) {
$.activityEnd = true;
break;
}
}
}
}
if (l11Ili.status == 200) {
iIll1(l11Ili);
}
}
} catch (lli1li) {
$.logErr(lli1li, l11Ili);
} finally {
lIl1I1();
}
});
});
}
function i1I11i() {
return new Promise(liIil1 => {
let IIiIi1 = {};
$.post(I1III1("api/task/share/getUserId", IIiIi1), async (I1i1, iiiii, iiiil) => {
try {
if (I1i1) {
console.log("" + JSON.stringify(I1i1));
console.log($.name + " getUserId API请求失败,请检查网路重试");
} else {
iiiil = JSON.parse(iiiil);
if (iiiil && iiiil.resp_code == 0) {
li11II && ($.shareUserId = iiiil?.["data"]?.["shareUserId"] || "", console.log("助力码:" + $.shareUserId), i1I111.push($.shareUserId));
$.helpResult = true;
} else {
console.log(iiiil.resp_msg);
for (let il11II of ["未开始", "结束", "不存在", "不在"]) {
if (iiiil.resp_msg.includes(il11II)) {
$.activityEnd = true;
break;
}
}
}
iiiii.status == 200 && iIll1(iiiii);
}
} catch (I1II1i) {
$.logErr(I1II1i, iiiii);
} finally {
liIil1();
}
});
});
}
function lI1l() {
return new Promise(iiIlIi => {
let iIlIll = {};
$.post(I1III1("api/task/share/friends", iIlIll), async (i11llI, iIIi1, iIiIIl) => {
try {
if (i11llI) {
console.log("" + JSON.stringify(i11llI));
console.log($.name + " friends API请求失败,请检查网路重试");
} else {
iIiIIl = JSON.parse(iIiIIl);
if (iIiIIl && iIiIIl.data) {
$.num = iIiIIl?.["data"]?.["num"] || 0;
$.friends = iIiIIl?.["data"]?.["friends"] || [];
} else {
console.log(iIiIIl.resp_msg);
for (let iIiIIi of ["未开始", "结束", "不存在", "不在"]) {
if (iIiIIl.resp_msg.includes(iIiIIi)) {
$.activityEnd = true;
break;
}
}
}
iIIi1.status == 200 && iIll1(iIIi1);
}
} catch (IlIili) {
$.logErr(IlIili, iIIi1);
} finally {
iiIlIi();
}
});
});
}
function li11Il() {
return new Promise(iiI1II => {
let lIiii1 = {};
$.post(I1III1("api/task/daySign/getSignClick", lIiii1), async (I1Iili, ilIIII, I1li) => {
try {
if (I1Iili) {
console.log("" + JSON.stringify(I1Iili));
console.log($.name + " getSignClick API请求失败,请检查网路重试");
} else {
I1li = JSON.parse(I1li);
if (I1li && I1li.resp_code == 0) {
if (!I1li.data) {
console.log("💨 空气");
} else {
drawInfo = I1li.data;
if (drawInfo) {
switch (drawInfo.prizeType) {
case 1:
console.log("🎉 " + drawInfo.prizeName + " 🐶");
break;
case 3:
generateId = I1li.data.prizeInfoId;
prizeName = drawInfo.prizeName;
addressId = drawInfo.addressId;
console.log("🎉 恭喜获得实物~");
console.log("奖品名称:" + prizeName);
process.env.jd_lzkj_loreal_address && (await i1I11l(addressId), await $.wait(4000));
break;
case 4:
case 11:
console.log("🎉 " + drawInfo.prizeName + " 🎟️");
break;
case 2:
console.log("🎉 " + drawInfo.prizeName + " 优惠券");
break;
case 8:
console.log("🎉 恭喜获得" + drawInfo.prizeName + " 🎁");
break;
default:
console.log(I1li.data);
break;
}
}
}
} else {
console.log(I1li.resp_msg);
for (let iilI1i of ["未开始", "结束", "不存在", "不在"]) {
if (I1li.resp_msg.includes(iilI1i)) {
$.activityEnd = true;
break;
}
}
}
ilIIII.status == 200 && iIll1(ilIIII);
}
} catch (I1IilI) {
$.logErr(I1IilI, ilIIII);
} finally {
iiI1II();
}
});
});
}
function i1I11l(lli1I) {
return new Promise(iI1i1I => {
let IiI11i = {
"realName": $.receiver,
"mobile": $.phone,
"address": $.address,
"orderCode": lli1I,
"province": $.province,
"city": $.city,
"county": $.county
};
$.post(I1III1("api/my/prize/update", IiI11i), async (iI1i1l, IiI11I, ll1ili) => {
try {
if (iI1i1l) {
console.log("" + JSON.stringify(iI1i1l));
console.log($.name + " update API请求失败,请检查网路重试");
} else {
ll1ili = JSON.parse(ll1ili);
if (ll1ili && ll1ili.resp_code == 0) console.log("地址填写成功");else {
if (ll1ili && ll1ili.resp_code == 50013 || ll1ili.resp_code == 50012) {} else {
if (ll1ili && ll1ili.resp_code == 2) console.log("请在一个小时内填写");else {
console.log(ll1ili);
for (let IiiiII of ["未开始", "结束", "不存在", "不在"]) {
if (ll1ili.resp_msg.includes(IiiiII)) {
$.activityEnd = true;
break;
}
}
}
}
}
IiI11I.status == 200 && iIll1(IiI11I);
}
} catch (llilli) {
$.logErr(llilli, IiI11I);
} finally {
iI1i1I();
}
});
});
}
function IIlIl1() {
return new Promise(llillI => {
let l1ii1I = {
"taskId": $.taskId,
"skuId": ""
};
$.post(I1III1("api/active/basicInfo", l1ii1I), async (IiIIi1, I11Iil, l1liI1) => {
try {
if (IiIIi1) {
console.log("" + JSON.stringify(IiIIi1));
console.log($.name + " basicInfo API请求失败,请检查网路重试");
} else {
l1liI1 = JSON.parse(l1liI1);
if (l1liI1 && l1liI1.resp_code == 0) {
$.actName = l1liI1.data.actName;
$.shopName = l1liI1.data.shopName;
} else {
console.log(l1liI1);
}
I11Iil.status == 200 && iIll1(I11Iil);
}
} catch (il1lil) {
$.logErr(il1lil, I11Iil);
} finally {
llillI();
}
});
});
}
function liII1l() {
return new Promise(l111li => {
let IiIlIl = {};
$.post(I1III1("api/prize/drawPrize", IiIlIl), async (iiliiI, Il1li, lIiI11) => {
try {
iiliiI ? (console.log("" + JSON.stringify(iiliiI)), console.log($.name + " drawPrize API请求失败,请检查网路重试")) : (lIiI11 = JSON.parse(lIiI11), lIiI11 && lIiI11.resp_code == 0 ? ($.drawNumber = lIiI11.data.drawNumber, $.prizeInfo = lIiI11.data.prizeInfo || []) : console.log(lIiI11), Il1li.status == 200 && iIll1(Il1li));
} catch (li1lI1) {
$.logErr(li1lI1, Il1li);
} finally {
l111li();
}
});
});
}
async function Ii1ll1() {
if (!$.joinVenderId) return;
return new Promise(async IiIIli => {
$.errorJoinShop = "活动太火爆,请稍后再试";
let iiliil = "";
if ($.shopactivityId) iiliil = ",\"activityId\":" + $.shopactivityId;
const il1llI = "{\"venderId\":\"" + $.joinVenderId + "\",\"shopId\":\"" + $.joinVenderId + "\",\"bindByVerifyCodeFlag\":1,\"registerExtend\":{},\"writeChildFlag\":0" + iiliil + ",\"channel\":406}",
il1ll1 = {
"appid": "jd_shop_member",
"functionId": "bindWithVender",
"clientVersion": "9.2.0",
"client": "H5",
"body": JSON.parse(il1llI)
},
Il11Ii = await I1IIIl("8adfb", il1ll1),
Il11Il = {
"url": "https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body=" + il1llI + "&clientVersion=9.2.0&client=H5&uuid=88888&h5st=" + encodeURIComponent(Il11Ii),
"headers": {
"accept": "*/*",
"accept-encoding": "gzip, deflate, br",
"accept-language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7",
"cookie": Ii1lli,
"origin": "https://shopmember.m.jd.com/",
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36"
}
};
$.get(Il11Il, async (I1ill, i111Il, i111Ii) => {
try {
if (I1ill) i111Il && typeof i111Il.statusCode != "undefined" && i111Il.statusCode == 403 && console.log("此ip已无法开卡,请更换IP后再执行脚本\n");else {
i111Ii = i111Ii && i111Ii.match(/jsonp_.*?\((.*?)\);/) && i111Ii.match(/jsonp_.*?\((.*?)\);/)[1] || i111Ii;
let i111II = $.toObj(i111Ii, i111Ii);
if (i111II && typeof i111II == "object") {
if (i111II && i111II.success === true) {
console.log(" >> " + i111II.message);
$.errorJoinShop = i111II.message;
if (i111II.result && i111II.result.giftInfo) {
for (let IiIIl1 of i111II.result.giftInfo.giftList) {
console.log(" >> 入会获得:" + IiIIl1.discountString + IiIIl1.prizeName + IiIIl1.secondLineDesc);
}
}
} else i111II && typeof i111II == "object" && i111II.message ? ($.errorJoinShop = i111II.message, console.log("" + (i111II.message || ""))) : console.log(i111Ii);
} else {
console.log(i111Ii);
}
}
} catch (IIi1II) {
$.logErr(IIi1II, i111Il);
} finally {
IiIIli();
}
});
});
}
async function IIlIlI() {
return new Promise(async IiliI1 => {
const l111 = "{\"venderId\":\"" + $.joinVenderId + "\",\"channel\":406,\"payUpShop\":true}",
il11lI = {
"appid": "jd_shop_member",
"functionId": "bindWithVender",
"clientVersion": "9.2.0",
"client": "H5",
"body": JSON.parse(l111)
},
lIll1I = await I1IIIl("8adfb", il11lI),
li1II1 = {
"url": "https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=" + l111 + "&clientVersion=9.2.0&client=H5&uuid=88888&h5st=" + encodeURIComponent(lIll1I),
"headers": {
"accept": "*/*",
"accept-encoding": "gzip, deflate, br",
"accept-language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7",
"cookie": Ii1lli,
"origin": "https://shopmember.m.jd.com/",
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36"
}
};
$.get(li1II1, async (iiIllI, iII1l1, I1I1I) => {
try {
if (iiIllI) iII1l1 && typeof iII1l1.statusCode != "undefined" && iII1l1.statusCode == 403 && console.log("此ip已无法开卡,请更换IP后再执行脚本\n");else {
I1I1I = I1I1I && I1I1I.match(/jsonp_.*?\((.*?)\);/) && I1I1I.match(/jsonp_.*?\((.*?)\);/)[1] || I1I1I;
let l1Ili = $.toObj(I1I1I, I1I1I);
l1Ili && typeof l1Ili == "object" ? l1Ili && l1Ili.success == true && (console.log("去加入:" + (l1Ili.result.shopMemberCardInfo.venderCardName || "") + " (" + $.joinVenderId + ")"), $.shopactivityId = l1Ili.result.interestsRuleList && l1Ili.result.interestsRuleList[0] && l1Ili.result.interestsRuleList[0].interestsInfo && l1Ili.result.interestsRuleList[0].interestsInfo.activityId || "") : console.log(I1I1I);
}
} catch (lllllI) {
$.logErr(lllllI, iII1l1);
} finally {
IiliI1();
}
});
});
}
function I1III1(Iiii1i, iiIlll) {
return {
"url": "" + Ii1lI + "/" + wxActType + "/" + Iiii1i,
"body": JSON.stringify(iiIlll),
"headers": {
"Accept": "application/json",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "zh-cn",
"Connection": "keep-alive",
"Host": $.domain,
"Origin": Ii1lI,
"Content-Type": "application/json;charset=UTF-8",
"Referer": lI11,
"Cookie": Ii1lli + iIiIli + ";IsvToken=" + $.token + ";AUTH_C_USER=" + $.AUTH_C_USER,
"User-Agent": $.UA,
"token": $.tokens
},
"timeout": 15 * 1000
};
}
function iIll1(Il1lIl) {
if (Il1lIl) {
if (Il1lIl.headers["set-cookie"]) {
Ii1lli = originCookie + ";";
for (let iiiiil of Il1lIl.headers["set-cookie"]) {
I1IIIi[iiiiil.split(";")[0].substr(0, iiiiil.split(";")[0].indexOf("="))] = iiiiil.split(";")[0].substr(iiiiil.split(";")[0].indexOf("=") + 1);
}
for (const l1Il11 of Object.keys(I1IIIi)) {
Ii1lli += l1Il11 + "=" + I1IIIi[l1Il11] + ";";
}
iIiIli = Ii1lli;
}
}
}
function l11li1(IIl1lI) {
return new Promise(illiII => {
const llllil = {
"url": IIl1lI + "?" + new Date(),
"timeout": 10000,
"headers": {
"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1 Edg/87.0.4280.88"
}
};
$.get(llllil, async (ilill, li1IIi, Il1IiI) => {
try {
if (ilill) $.getAuthorCodeListerr = false;else {
if (Il1IiI) Il1IiI = JSON.parse(Il1IiI);
$.getAuthorCodeListerr = true;
}
} catch (IiIl1l) {
$.logErr(IiIl1l, li1IIi);
Il1IiI = null;
} finally {
illiII(Il1IiI);
}
});
});
}
function i1I(iiiiiI) {
iiiiiI = iiiiiI || 32;
let IIl1li = "abcdef0123456789",
l11i = IIl1li.length,
IIl1ll = "";
for (i = 0; i < iiiiiI; i++) IIl1ll += IIl1li.charAt(Math.floor(Math.random() * l11i));
return IIl1ll;
}
function liII1I(il11li, il11ll) {
let Il1Ii1 = new RegExp("(^|[&?])" + il11ll + "=([^&]*)(&|$)"),
ililI = il11li.match(Il1Ii1);
if (ililI != null) return unescape(ililI[2]);
return "";
}
function iIiIiI(lIlII1) {
if (!lIlII1) return console.log("京东服务器返回数据为空"), false;
try {
if (typeof JSON.parse(lIlII1) == "object") {
return true;
}
} catch (I11lII) {
return console.log(I11lII), false;
}
}
function iIlil(iiiil1) {
if (typeof iiiil1 == "string") try {
return JSON.parse(iiiil1);
} catch (iliil) {
return console.log(iliil), $.msg($.name, "", "请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie"), [];
}
}
function lIiII1(lIiiI, iiiilI) {
return Math.floor(Math.random() * (iiiilI - lIiiI)) + lIiiI;
}
function Env(t, e) { "undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0); class s { constructor(t) { this.env = t } send(t, e = "GET") { t = "string" == typeof t ? { url: t } : t; let s = this.get; return "POST" === e && (s = this.post), new Promise((e, i) => { s.call(this, t, (t, s, r) => { t ? i(t) : e(s) }) }) } get(t) { return this.send.call(this.env, t) } post(t) { return this.send.call(this.env, t, "POST") } } return new class { constructor(t, e) { this.name = t, this.http = new s(this), this.data = null, this.dataFile = "box.dat", this.logs = [], this.isMute = !1, this.isNeedRewrite = !1, this.logSeparator = "\n", this.startTime = (new Date).getTime(), Object.assign(this, e), this.log("", `🔔${this.name}, 开始!`) } isNode() { return "undefined" != typeof module && !!module.exports } isQuanX() { return "undefined" != typeof $task } isSurge() { return "undefined" != typeof $httpClient && "undefined" == typeof $loon } isLoon() { return "undefined" != typeof $loon } toObj(t, e = null) { try { return JSON.parse(t) } catch { return e } } toStr(t, e = null) { try { return JSON.stringify(t) } catch { return e } } getjson(t, e) { let s = e; const i = this.getdata(t); if (i) try { s = JSON.parse(this.getdata(t)) } catch { } return s } setjson(t, e) { try { return this.setdata(JSON.stringify(t), e) } catch { return !1 } } getScript(t) { return new Promise(e => { this.get({ url: t }, (t, s, i) => e(i)) }) } runScript(t, e) { return new Promise(s => { let i = this.getdata("@chavy_boxjs_userCfgs.httpapi"); i = i ? i.replace(/\n/g, "").trim() : i; let r = this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout"); r = r ? 1 * r : 20, r = e && e.timeout ? e.timeout : r; const [o, h] = i.split("@"), n = { url: `http://${h}/v1/scripting/evaluate`, body: { script_text: t, mock_type: "cron", timeout: r }, headers: { "X-Key": o, Accept: "*/*" } }; this.post(n, (t, e, i) => s(i)) }).catch(t => this.logErr(t)) } loaddata() { if (!this.isNode()) return {}; { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e); if (!s && !i) return {}; { const i = s ? t : e; try { return JSON.parse(this.fs.readFileSync(i)) } catch (t) { return {} } } } } writedata() { if (this.isNode()) { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e), r = JSON.stringify(this.data); s ? this.fs.writeFileSync(t, r) : i ? this.fs.writeFileSync(e, r) : this.fs.writeFileSync(t, r) } } lodash_get(t, e, s) { const i = e.replace(/\[(\d+)\]/g, ".$1").split("."); let r = t; for (const t of i) if (r = Object(r)[t], void 0 === r) return s; return r } lodash_set(t, e, s) { return Object(t) !== t ? t : (Array.isArray(e) || (e = e.toString().match(/[^.[\]]+/g) || []), e.slice(0, -1).reduce((t, s, i) => Object(t[s]) === t[s] ? t[s] : t[s] = Math.abs(e[i + 1]) >> 0 == +e[i + 1] ? [] : {}, t)[e[e.length - 1]] = s, t) } getdata(t) { let e = this.getval(t); if (/^@/.test(t)) { const [, s, i] = /^@(.*?)\.(.*?)$/.exec(t), r = s ? this.getval(s) : ""; if (r) try { const t = JSON.parse(r); e = t ? this.lodash_get(t, i, "") : e } catch (t) { e = "" } } return e } setdata(t, e) { let s = !1; if (/^@/.test(e)) { const [, i, r] = /^@(.*?)\.(.*?)$/.exec(e), o = this.getval(i), h = i ? "null" === o ? null : o || "{}" : "{}"; try { const e = JSON.parse(h); this.lodash_set(e, r, t), s = this.setval(JSON.stringify(e), i) } catch (e) { const o = {}; this.lodash_set(o, r, t), s = this.setval(JSON.stringify(o), i) } } else s = this.setval(t, e); return s } getval(t) { return this.isSurge() || this.isLoon() ? $persistentStore.read(t) : this.isQuanX() ? $prefs.valueForKey(t) : this.isNode() ? (this.data = this.loaddata(), this.data[t]) : this.data && this.data[t] || null } setval(t, e) { return this.isSurge() || this.isLoon() ? $persistentStore.write(t, e) : this.isQuanX() ? $prefs.setValueForKey(t, e) : this.isNode() ? (this.data = this.loaddata(), this.data[e] = t, this.writedata(), !0) : this.data && this.data[e] || null } initGotEnv(t) { this.got = this.got ? this.got : require("got"), this.cktough = this.cktough ? this.cktough : require("tough-cookie"), this.ckjar = this.ckjar ? this.ckjar : new this.cktough.CookieJar, t && (t.headers = t.headers ? t.headers : {}, void 0 === t.headers.Cookie && void 0 === t.cookieJar && (t.cookieJar = this.ckjar)) } get(t, e = (() => { })) { t.headers && (delete t.headers["Content-Type"], delete t.headers["Content-Length"]), this.isSurge() || this.isLoon() ? (this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.get(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) })) : this.isQuanX() ? (this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t))) : this.isNode() && (this.initGotEnv(t), this.got(t).on("redirect", (t, e) => { try { if (t.headers["set-cookie"]) { const s = t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString(); s && this.ckjar.setCookieSync(s, null), e.cookieJar = this.ckjar } } catch (t) { this.logErr(t) } }).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) })) } post(t, e = (() => { })) { if (t.body && t.headers && !t.headers["Content-Type"] && (t.headers["Content-Type"] = "application/x-www-form-urlencoded"), t.headers && delete t.headers["Content-Length"], this.isSurge() || this.isLoon()) this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.post(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) }); else if (this.isQuanX()) t.method = "POST", this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t)); else if (this.isNode()) { this.initGotEnv(t); const { url: s, ...i } = t; this.got.post(s, i).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) }) } } time(t, e = null) { const s = e ? new Date(e) : new Date; let i = { "M+": s.getMonth() + 1, "d+": s.getDate(), "H+": s.getHours(),"h+": s.getHours(), "m+": s.getMinutes(), "s+": s.getSeconds(), "q+": Math.floor((s.getMonth() + 3) / 3), "S+": s.getMilliseconds() }; /(y+)/.test(t) && (t = t.replace(RegExp.$1, (s.getFullYear() + "").substr(4 - RegExp.$1.length))); for (let e in i) new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? i[e] : ("00" + i[e]).substr(("" + i[e]).length))); return t } msg(e = t, s = "", i = "", r) { const o = t => { if (!t) return t; if ("string" == typeof t) return this.isLoon() ? t : this.isQuanX() ? { "open-url": t } : this.isSurge() ? { url: t } : void 0; if ("object" == typeof t) { if (this.isLoon()) { let e = t.openUrl || t.url || t["open-url"], s = t.mediaUrl || t["media-url"]; return { openUrl: e, mediaUrl: s } } if (this.isQuanX()) { let e = t["open-url"] || t.url || t.openUrl, s = t["media-url"] || t.mediaUrl; return { "open-url": e, "media-url": s } } if (this.isSurge()) { let e = t.url || t.openUrl || t["open-url"]; return { url: e } } } }; if (this.isMute || (this.isSurge() || this.isLoon() ? $notification.post(e, s, i, o(r)) : this.isQuanX() && $notify(e, s, i, o(r))), !this.isMuteLog) { let t = ["", "==============📣系统通知📣=============="]; t.push(e), s && t.push(s), i && t.push(i), console.log(t.join("\n")), this.logs = this.logs.concat(t) } } log(...t) { t.length > 0 && (this.logs = [...this.logs, ...t]), console.log(t.join(this.logSeparator)) } logErr(t, e) { const s = !this.isSurge() && !this.isQuanX() && !this.isLoon(); s ? this.log("", `❗️${this.name}, 错误!`, t.stack) : this.log("", `❗️${this.name}, 错误!`, t) } wait(t) { return new Promise(e => setTimeout(e, t)) } done(t = {}) { const e = (new Date).getTime(), s = (e - this.startTime) / 1e3; this.log("", `🔔${this.name}, 结束! 🕛 ${s} 秒`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t) } }(t, e) }