forked from Xiao233-q/jddp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjd_dpqd_fcwbhelp.js
731 lines (698 loc) · 27 KB
/
jd_dpqd_fcwbhelp.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
/**
* cron: 0 0,1,9 * * *
*/
console.log('当前版本号', '20230101-v1.0')
console.log('若脚本报错则增加变量TK_SIGN_method为planb再试一次,还不行就用旧脚本!')
const yxl = require('./depend/yxl')
const $ = new yxl.Env('挖宝助力(店铺签到专用)');
const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''
const notify = $.isNode() ? require('./sendNotify') : ''
const linkId = 'pTTvJeSTrpthgk9ASBVGsw'
const axios = require('axios')
if(process.env.TK_SIGN_method&&process.env.TK_SIGN_method=='planb'){
$.changeplan=true
}else{
$.changeplan=false
}
let blacklist = '' // 黑名单 用&隔开 pin值(填中文
let nowHours = new Date().getHours(),
codestemp='',
PROXY_HOST ='',
PROXY_PORT ='',
wbh5st='',
cookiesArr = [],
helpToolsArr = [],
helpCookiesArr = [],
available='',
sendFlag = true,
allMessage = '',
message = '',
timeDelayG=300000,
timeDelayN=300000
if(process.env.TK_SIGN_ID){
$.TK_SIGN_ID=process.env.TK_SIGN_ID||''
$.TK_SIGN_SIGN=process.env.TK_SIGN_SIGN||''
$.TK_SIGN ={id:$.TK_SIGN_ID,sign:$.TK_SIGN_SIGN}
}else if(process.env.TK_SIGN){
$.TK_SIGN=process.env.TK_SIGN
$.TK_SIGN=$.toObj($.TK_SIGN,$.TK_SIGN)
}else {
console.log('联系@dpqd_boss获取TK_SIGN.')
}
if ($.isNode()) {
Object.keys(jdCookieNode).forEach((item) => {
cookiesArr.push(jdCookieNode[item])
})
} else {
cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || '[]').map(item => item.cookie)].filter(item => !!item)
}
$.dpqd_help_list = $.getdata("dpqd_help_list") || {}
$.dpqd_help_list = $.toObj($.dpqd_help_list,$.dpqd_help_list)
if(typeof $.dpqd_help_list != "object"){
$.dpqd_help_list = {}
}
$.dpqd_help = {}
if($.dpqd_help_list[$.time("MM_dd")]){
$.dpqd_help = $.dpqd_help_list[$.time("MM_dd")]
}
$.userhot = false
$.toStatus = false
$.jdStatus = true
$.hotFlag = false
$.errMsgPin = []
$.totalhelptimes=0
$.successhelptimes=0
$.PROXY_LIST=[]
!(async () => {
console.log(typeof $.TK_SIGN.id,`TK_SIGN.id:${$.toStr($.TK_SIGN.id)}`);
//验证服务器连接耗时
if(new Date().getHours()>21){
console.log('数据都清空了,别跑了!等零点再跑!')
return
}
await $.wait(yxl.randomNumber(1000, 10000))
$.apidata = await yxl[$.changeplan?'readapi1':'readapi']('TOKEN',$.TK_SIGN.id,$.TK_SIGN.sign)
$.apidata=$.toObj($.apidata,$.apidata)
if(typeof $.apidata != "object"){
$.apidata = []
return
}
//读取黑名单,不写入
$.blacklist = ''
if ($.apidata.wbblacklist == 'retain') {
$.dpqd_black_list = $.getdata("dpqd_black_list") || {}
$.dpqd_black_list = $.toObj($.dpqd_black_list, $.dpqd_black_list)
if (typeof $.dpqd_black_list != "object") {
$.dpqd_black_list = {}
}
if ($.dpqd_black_list["wabao"]) {
$.blacklist = $.dpqd_black_list["wabao"].join('&')
}
}
//读取黑名单
if (process.env.TK_SIGN_info&&process.env.TK_SIGN_info==="info"){
console.log(`截图报错日志发到群里!`)
} else{
console.log(`如果报错,增加变量TK_SIGN_info值为info可显示详细报错原因!`)
console.info = () => { }
}
await ping()
//等到0点0分20秒$.apidata.begain值为开始秒数
if(new Date().getHours()==0){
$.zerotime=await yxl.zerotime($.apidata.begain*1000) //单位毫秒
if($.zerotime<120000){
console.log(`还未获取到助力码,等待${$.zerotime/1000}秒......`);
await $.wait($.zerotime)
}
}
// 验证是否获取到助力码
for(let i=1;i<8;i++){
new Date().getHours()==0||i>1?$.apidata = await yxl[$.changeplan?'readapi1':'readapi']('TOKEN',$.TK_SIGN.id,$.TK_SIGN.sign):''
$.apidata = $.toObj($.apidata,$.apidata)
if(typeof $.apidata != "object"){
continue
}
$.fcwb = $.apidata.fcwb
$.fcwb=$.toObj($.fcwb,$.fcwb)
console.info(`获取到fcwb:\n${$.toStr($.fcwb)}`);
$.PROXY_LIST = $.apidata.plist
$.PROXY_LIST=$.toObj($.PROXY_LIST,$.PROXY_LIST)
console.info(`获取到PROXY_LIST:\n${$.toStr($.PROXY_LIST)}`);
if ($.fcwb.length === 0) {
console.log(`还未获取到助力码,${i===6?600:i*5}s后继续`);
await $.wait(i===6?600000:i*5000)
}else{
console.log('获取到助力码,可以继续下一步!')
break
}
i==6?console.log('最终无法获取到助力码,退出!'):''
}
if ($.fcwb.length === 0) {;
return
}
$.h5stTK=$.apidata.h5stTK
$.h5stTK=$.toObj($.h5stTK,$.h5stTK)
console.info('h5stTK:',$.h5stTK)
// 获取紧急通知
if($.apidata.notify!=='null'){
console.log("\n=========通知=========\n",$.apidata.notify)
message+="\n======通知======\n"+$.apidata.notify+"\n"
await notify.sendNotify(`${$.name}`, `${message}`);
}
// 根据设定运行时间启动助力
if (nowHours==0||nowHours==23||$.apidata.runtime>0){
//执行助力
console.info(`设定运行时间:${$.apidata.runtime}点!`);
console.log(`该你助力了,开始助力!`)
$.sendNotifyStatus = false // 发送消息 true 为发送 false 不发送 默认 true
$.maxHelpNumber = $.apidata.maxtime*1 // 最大助力成功次数
$.maxHelpErrCount = 50 // 连续"活动太火爆了,请稍后重试"及访问京东API失败次数超过此值则停止助力
await getBlacklist()
helpCookiesArr = $.toObj($.toStr(cookiesArr,cookiesArr))
if (!cookiesArr[0]) {
$.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', {
'open-url': 'https://bean.m.jd.com/'
})
return
}
$.sendNotifyStatus = process.env.dpqd_wb_sendNotifyStatus || $.sendNotifyStatus + '' || true // 是否发送消息
console.log(`\n------ 变量设置 ------`)
console.log(`${$.sendNotifyStatus+'' == 'true' ? '发送' : '不发送'}消息📜`)
// ===========================================================================
console.log("\n开始获取用于助力的账号列表")
for (let i in cookiesArr) {
// 将用于助力的账号加入列表
let UserName = decodeURIComponent(cookiesArr[i].match(/pt_pin=([^; ]+)(?=;?)/) && cookiesArr[i].match(/pt_pin=([^; ]+)(?=;?)/)[1])
helpToolsArr.push({id: i, UserName, assisted: false, cookie: cookiesArr[i]})
}
console.log(`用于助力的数目为 ${helpToolsArr.length}`)
allMessage += `用于助力的数目为 ${helpToolsArr.length}\n`
$.updateHelpData = false
await run()
// await $.wait(2000)
if (new Date().getHours() == 0) {
console.log('本次助力次数:',$.totalhelptimes)
await yxl[$.changeplan?'count1':'count']($.TK_SIGN.id,$.TK_SIGN.sign,'totalhelptimes',$.totalhelptimes)
}
console.log('本次助力成功次数',$.successhelptimes)
allMessage += `本次助力成功次数 ${$.successhelptimes}\n`
await yxl[$.changeplan?'count1':'count']($.TK_SIGN.id,$.TK_SIGN.sign,'successhelptimes',$.successhelptimes)
if ($.successhelptimes === 0 && new Date().getHours() == 0) {
console.log('你的第一次给了谁?')
allMessage += `助力一直为零签到数据将停更!\n`
}
//其他时段签到
}else{
console.log(`您今日已助力过,不再运行!`)
}
//发送消息
if(allMessage){
if($.errMsgPin.length > 0&&$.apidata.wbblacklist=='clean'){
console.log(`以下账号可能是火爆,已加入黑名单缓存\ndpqd_wb_blacklist="${$.errMsgPin.join('&')}"`)
}
$.msg($.name, '', `${allMessage}`)
if ($.isNode() && sendFlag && $.sendNotifyStatus+'' == 'true'){
await notify.sendNotify(`${$.name}`, `${allMessage}`);
}
if ($.isNode() && sendFlag && $.apidata.notify!=='null'){
await notify.sendNotify(`${$.name}`, `${allMessage}`);
}
}
})()
.catch((e) => console.log(e))
.finally(() => $.done())
async function run() {
let help = ''
console.info('开始获取助力信息!')
help = await getwbzlm()
console.info('获取助力信息:',help)
try {
console.info('助力cookie数量:',helpCookiesArr.length)
$.totalhelptimes=helpCookiesArr.length
for(let i = 0; i < helpCookiesArr.length; i++) {
//$.UA=yxl.JS_USER_AGENT
$.UA=`jdltapp;iPhone;3.8.22;${Math.ceil(Math.random() * 4 + 10)}.${Math.ceil(Math.random() * 4)};${randomString(40)};Mozilla/5.0 (Linux; Android 10; PCCM00 Build/QKQ1.191021.002; wv)AppleWebKit/537.36 (KHTML like Gecko) Version/4.0 Chrome/102.0.5005.125MobileSafari/537.36;`
console.info('UA:',$.UA)
if(help && help.inviteCode && help.inviter && !$.hotFlag){
if(help.helpNumber < $.maxHelpNumber){
console.info('开始助力!')
await helpProcess(help)
}
if(help.msg){
allMessage += `助力信息:${help.msg}\n\n`
}
}
if($.hotFlag){
break
}
}
//挖宝黑名单清空并写入
if ($.userhot && $.apidata.wbblacklist == 'clean') {
await yxl[$.changeplan ? 'count1' : 'count']($.TK_SIGN.id, $.TK_SIGN.sign, 'userhot', 1)
$.dpqd_black_list = {}
$.dpqd_black_list["wabao"] = $.errMsgPin
$.setdata($.dpqd_black_list, 'dpqd_black_list')
}
//挖宝黑名单覆盖
} catch (e) {
console.log(e)
}
}
async function ping() {
// 开始检测API接口是否能直接访问
console.log(`开始检测API接口是否能直接访问!`)
if($.apidata.h5stchose=='n'||$.apidata.h5stchose=='ng'){
starttime=Date.now()
let Status=$.changeplan?await checkserver1('https://api.nolanstore.top/ping'):await checkserver('https://api.nolanstore.top/ping')
console.info('N接口:',Status)
if(Status*1 == 200){
$.toStatus = true
endtime=Date.now()
timeDelayN=endtime-starttime
console.log('N接口可用,用时!',timeDelayN)
}else{console.log('N接口无法直接访问!')}
}
if($.apidata.h5stchose=='g'||$.apidata.h5stchose=='ng'){
starttime=Date.now()
let Status=$.changeplan?await checkserver1('https://jd.smiek.tk/to_status'):await checkserver('https://jd.smiek.tk/to_status')
console.info('G接口:',Status)
if(Status*1== 200){
$.toStatus = true
endtime=Date.now()
timeDelayG=endtime-starttime
console.log('G接口可用,用时',timeDelayG)
}else{console.log('G接口无法直接访问!')}
}
if(!$.toStatus){
console.log('无法连接服务器,将使用代理访问接口!')
}else{
timeDelayN<timeDelayG ? available='N' :available='G'
console.log(available,'成功连接服务器!')
}
}
async function helpProcess(help) {
if($.PROXY_LIST.length>0){
let pnum=await yxl.randomNumber(0, $.PROXY_LIST.length-1)
let prox=$.PROXY_LIST[pnum]
prox=$.toObj(prox,prox)
console.info('使用代理:',$.toStr(prox))
PROXY_HOST=prox.ip
PROXY_PORT=prox.port
}
while (helpToolsArr.length > 0) {
let tool = helpToolsArr.pop()
if($.dpqd_help[tool.UserName]){
console.log('☹️',Number(tool.id)+1,$.dpqd_help[tool.UserName],'跳过')
continue
}
if (help.UserName && tool.UserName == help.UserName) {
helpToolsArr.unshift(tool)
}
let isLogin = await getLogin(tool.UserName, tool.cookie)
if(isLogin){
console.log('👉',Number(tool.id)+1,tool.UserName,'开始助力')
if(available=='N'){
await helpUserN(help, tool)
} else if(available=='G'){
await helpUserG(help, tool)
} else(await helpUserN(help, tool))
}else{
console.log(' 😭',Number(tool.id)+1,tool.UserName,'登录失败')
continue
}
// await $.wait(10000) // 延迟
if($.hotFlag){
break
}
if (help.assist_full || $.successhelptimes >= $.maxHelpNumber) {
console.log(`🎉${help.UserName} 助力完成`)
$.hotFlag = true
break
}else if(help.assist_out || help.helpErrCount >= $.maxHelpErrCount){
console.log(`😴退出执行`)
$.hotFlag = true
break
}
}
if($.updateHelpData){
$.dpqd_help_list = {}
$.dpqd_help_list[$.time("MM_dd")] = $.dpqd_help
$.setdata($.dpqd_help_list, 'dpqd_help_list')
}
}
async function helpUserG(help, tool) {
try{
let res = ''
let h5st_res = ''
let timestamp = Date.now()
const body_in = { "linkId": linkId, "inviter": help.inviter, "inviteCode": help.inviteCode };
const h5st_body = {
appid: 'activities_platform',
body: $.toStr(body_in, body_in),
client: 'ios',
clientVersion: '4.5.0',
functionId: "happyDigHelp",
t: timestamp.toString()
}
for (let i = 0; i < 3; i++) {
if(!$.toStatus||!$.jdStatus){
console.log(' 🩸getproxy:','http://'+PROXY_HOST+':'+PROXY_PORT )
}
h5st_res = await yxl[$.changeplan?'getLog1':'getLog']($.TK_SIGN.id,$.apidata.appId,tool.UserName,h5st_body,$.h5stTK,$.toStatus,PROXY_HOST,PROXY_PORT)
if(h5st_res && typeof h5st_res == 'object' && h5st_res.code == 200 && h5st_res.data && h5st_res.data.h5st){
res = h5st_res.data
// console.log(res)
break
}
}
if(!res){
console.log(' 😵获取不到算法')
$.hotFlag = true
return
}
if(res.ua){
$.UA = res.ua
}
h5st = res.h5st || ''
let ck = tool.cookie
await requestApiG('happyDigHelp', ck, body_in, timestamp.toString(), h5st).then(async function (data) {
// console.log(data)
let desc = data.success && "助力成功" || data.errMsg || ""
if (desc) {
if (/助力成功/.test(desc)) {
await $.wait($.apidata.delay*1000)
$.dpqd_help[tool.UserName] = "已助力「"+help.UserName+"」"
help.helpCount += 1
$.successhelptimes++
tool.assisted = true
$.updateHelpData = true
help.helpErrCount = 0
} else if (/参与者参与次数达到上限/.test(desc)) {
$.dpqd_help[tool.UserName] = "已助力他人"
tool.assisted = true
$.updateHelpData = true
help.helpErrCount = 0
$.totalhelptimes--
} else if (/已经邀请过/.test(desc)) {
$.dpqd_help[tool.UserName] = "已助力「"+help.UserName+"」"
tool.assisted = true
$.updateHelpData = true
help.helpErrCount = 0
} else if (/^活动太火爆了,请稍后重试$/.test(desc)) {
help.helpErrCount++
$.userhot = true
desc = '账号火爆或者算法失效'
$.errMsgPin.push(tool.UserName)
if(help.helpErrCount >= $.maxHelpErrCount){
help.msg = desc
$.errMsgPin = []
}
} else {
if(data.rtn_code != 0) //console.log(data)
// success
// 活动太火爆了,请稍后重试
// 已经邀请过
// 参与者参与次数达到上限
tool.assisted = true
}
} else {
// undefined
tool.assisted = true
}
console.log(` ❤️${Number(tool.id)+1}->${(help.UserName).substring(0,5)}`, desc)
})
}catch(e){
console.log(e)
}
}
async function helpUserN(help, tool) {
try{
let h5st_res = ''
let body={"linkId": "pTTvJeSTrpthgk9ASBVGsw","inviter": codestemp.inviter,"inviteCode": codestemp.inviteCode}
for (let i = 0; i < 3; i++) {
if(!$.toStatus||!$.jdStatus){
console.log(' 🩸getproxy:','http://'+PROXY_HOST+':'+PROXY_PORT)
}
h5st_res = await yxl[$.changeplan?'geth5st1':'geth5st']($.TK_SIGN.id,$.apidata.appId,'happyDigHelp',body,$.UA,tool.UserName,$.h5stTK,$.toStatus,PROXY_HOST,PROXY_PORT)
if(h5st_res && typeof h5st_res == 'object' && h5st_res.code == 200 && h5st_res.body){
wbh5st = h5st_res.body
// console.log(res)
break
}
}
if(!wbh5st){
console.log(' 😵获取不到算法')
$.hotFlag = false
return
}
let ck = tool.cookie
await requestApiN(ck, wbh5st).then(async function (data) {
// console.log(data)
let desc = data.success && "助力成功" || data.errMsg || ""
if (desc) {
if (/助力成功/.test(desc)) {
await $.wait($.apidata.delay*1000)
$.dpqd_help[tool.UserName] = "已助力「"+help.UserName+"」"
help.helpCount += 1
$.successhelptimes++
tool.assisted = true
$.updateHelpData = true
help.helpErrCount = 0
} else if (/参与者参与次数达到上限/.test(desc)) {
$.dpqd_help[tool.UserName] = "已助力他人"
tool.assisted = true
$.updateHelpData = true
help.helpErrCount = 0
$.totalhelptimes--
} else if (/已经邀请过/.test(desc)) {
$.dpqd_help[tool.UserName] = "已助力「"+help.UserName+"」"
tool.assisted = true
$.updateHelpData = true
help.helpErrCount = 0
} else if (/^活动太火爆了,请稍后重试$/.test(desc)) {
$.userhot = true
help.helpErrCount++
desc = '账号火爆或者算法失效'
$.errMsgPin.push(tool.UserName)
if(help.helpErrCount >= $.maxHelpErrCount){
help.msg = desc
$.errMsgPin = []
}
} else {
if(data.rtn_code != 0) //console.log(data)
// success
// 活动太火爆了,请稍后重试
// 已经邀请过
// 参与者参与次数达到上限
tool.assisted = true
}
} else {
// undefined
tool.assisted = true
}
console.log(` ❤️${Number(tool.id)+1}->${(help.UserName).substring(0,5)}`, desc)
})
}catch(e){
console.log(e)
}
}
// 获取发财挖宝助力码固定
async function getwbzlm(){
let helpNumber = 0
let assist_out = false
let msg = ''
codestemp=$.fcwb[0]
let UserName=codestemp.inviter
return {
inviteCode: codestemp.inviteCode,
inviter: codestemp.inviter,
assist_full: false,
assist_out: assist_out,
UserName,
msg,
helpCount: 0,
helpNumber: helpNumber
}
}
async function requestApiG(functionId, cookie, body = {}, t = Date.now(), h5st = '') {
try{
let ck = cookie
let client = "H5"
$.clientVersion = ""
if(functionId == 'happyDigHelp'){
$.clientVersion = $.UA.split(';')[2]
// $.clientVersion = "3.9.0"
client = "ios"
}
return new Promise(async resolve => {
let options = {
url: `https://api.m.jd.com/?functionId=${functionId}&body=${encodeURIComponent($.toStr(body))}&t=${t}&appid=activities_platform&client=${client}&clientVersion=${$.clientVersion ? $.clientVersion : '1.2.0'}${h5st ? '&h5st=' + h5st : ''}`,
headers: {
"Accept": "application/json, text/plain, */*",
"Accept-Language": "zh-cn",
"Accept-Encoding": "gzip, deflate, br",
"Cookie": ck,
"origin": "https://bnzf.jd.com",
"Referer": "https://bnzf.jd.com/",
"User-Agent": $.UA,
}
}
if(!$.jdStatus){proxy(options)}
$.get(options, async (err, resp, data) => {
try {
if (err) {
//console.log(`🛠️${$.toStr(err)}`)
console.log(` 🛠️${$.name} requestApiG请求失败!`)
help.helpErrCount++
$.jdStatus = false
} else {
data = $.toObj(data,data)
}
} catch (e) {
console.log(e)
} finally {
resolve(data)
}
});
})
}catch(e){
console.log(e)
}
}
async function requestApiN(cookie, wbh5st) {
$.randomNum = parseInt(Math.random() * 888888 + 111111, 10);
let url = ` https://api.m.jd.com/?${wbh5st}&cthr=1&uuid=9366134603335346-2356564626${$.randomNum}&build=&screen=&networkType=&d_brand=&d_model=&lang=zh_CN&osVersion=&partner=&eid=`;
try{
return new Promise(async resolve => {
let options = {
url: url,
headers: {
'Host': 'api.m.jd.com',
'Origin': 'https://bnzf.jd.com',
'User-Agent': $.UA,
'Referer': "https://bnzf.jd.com/",
'Cookie': cookie,
'x-requested-with': "com.jd.jdlite"
}
}
$.get(options, async (err, resp, data) => {
try {
if (err) {
//console.log(` 🛠️${$.toStr(err)}`)
console.log(` 🛠️${$.name} requestApiN请求失败!`)
help.helpErrCount++
$.jdStatus = false
} else {
data = $.toObj(data,data)
}
} catch (e) {
console.log(e)
} finally {
resolve(data)
}
});
})
}catch(e){
console.log(e)
}
}
async function getLogin(UserName, ck) {
console.info('开始检测cookie是否有效!')
return new Promise(resolve => {
let options = {
url: `https://me-api.jd.com/user_new/info/GetJDUserInfoUnion`,
headers: {
"Accept": "*/*",
"Connection": "keep-alive",
"Accept-Language": "zh-cn",
"Accept-Encoding": "gzip, deflate, br",
"Cookie": ck,
"Referer": "https://home.m.jd.com/myJd/newhome.action?sceneval=2&ufc=&",
"User-Agent": "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",
},
timeout:10000
}
let msg = true
$.get(options, async (err, resp, data) => {
try {
if (err) {
//console.log(`🛠️${$.toStr(err)}`)
console.log(` 🛠️${$.name} ck有效 API请求失败,请检查网路重试`)
} else {
let res = $.toObj(data, data)
if (res.retcode+"" === "13" || res.retcode+"" === "1001") {
msg = false
console.log(` 🛠️账号「${UserName}」 Cookie失效`)
}else{
msg = true
}
}
} catch (e) {
console.log(e)
} finally {
resolve(msg);
}
})
})
}
//连接测试
async function checkserver1(url) {
let respcode=''
return new Promise(resolve => {
let options = {
url: url,
timeout: 20000
}
$.get(options, async (err, resp, data) => {
console.info(data)
try {
if (err) {
console.info(`连接服务器失败:`,err)
} else {
let res = $.toObj(resp,resp)
if(res && typeof res == 'object'){
respcode=res.status
}
}
} catch (e) {
console.info(e)
} finally {
resolve(respcode)
}
})
})
}
async function checkserver(url) {
try {
let config = {timeout: 20000}
let {status,data} = await axios.get(url, config)
console.info(status,data)
return status
} catch (e) {console.info('连接服务器失败!\n',e)}
}
/**
* 黑名单
*/
async function getBlacklist(){
if($.blacklist == '') return
console.log('------- 黑名单(对只有一个账号且也是黑号无效) -------')
const result = Array.from(new Set($.blacklist.split('&'))) // 数组去重
console.log(`${result.join('\n')}`)
let blacklistArr = result
let arr = []
let g = false
for (let i = 0; i < cookiesArr.length; i++) {
let s = decodeURIComponent((cookiesArr[i].match(/pt_pin=([^; ]+)(?=;?)/) && cookiesArr[i].match(/pt_pin=([^; ]+)(?=;?)/)[1]) || '')
if(!s) break
let f = false
for(let n of blacklistArr){
if(n && n == s){
f = true
break
}
}
if(!f){
g = true
arr.splice(i,-1,cookiesArr[i])
}
}
if(g) cookiesArr = arr
}
function jsonParse(str) {
if (typeof str == 'string') {
try {
return JSON.parse(str)
} catch (e) {
console.log(e)
$.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie')
return []
}
}
}
function randomString(e) {
e = e || 32
let t = 'abcdef0123456789', a = t.length, n = ''
for (i = 0; i < e; i++)
n += t.charAt(Math.floor(Math.random() * a))
return n
}