-
Notifications
You must be signed in to change notification settings - Fork 188
/
KWW.js
3502 lines (3347 loc) · 140 KB
/
KWW.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
/**
*
* 项目名称:口味王小程序
* 项目抓包:抓tls-xw.mengniu.cn下的memberId & memberUnionid填入变量
* 项目变量:KWW
* 项目定时:每天9,18,20
* cron: 0 9,18,20 * * *
* github仓库:https://github.com/CHERWING/CHERWIN_SCRIPTS
*
*/
//===============脚本版本=================//
let local_version = "2024.05.24";
//=======================================//
const APP_NAME = '口味王小程序'
const $ = new Env('口味王小程序');
const ENV_NAME = 'KWW'
const notify = $.isNode() ? require('./sendNotify') : '';
const Notify = 1 //0为关闭通知,1为打开通知,默认为1
const JSEncrypt = require('node-jsencrypt');
const axios = require('axios');
const parser = require("@babel/parser");
const fs = require('fs');
const path = require('path');
const xpath = require('xpath')
, XmldomParser = require('xmldom').DOMParser;
const domParser = new XmldomParser({
errorHandler: {}
})
const {JSDOM} = require('jsdom');
let request = require("request");
request = request.defaults({jar: true});
const {log} = console;
let APP_CONFIG = "";
let UserCookie = ($.isNode() ? process.env.KWW : process.env.KWW ) || '';
let SCRIPT_UPDATE = process.env.SCRIPT_UPDATE || true;
// console.log(process.env.KWW)
let UserCookieArr = [];
let data = '';
let msg =``;
let one_msg = '';
let isSign = false;
let signCateId = '';
let signRulesName = '';
let signParamNo = '';
let signOrderNo = '';
let userKeys = 'v1.0';
let formName = 'searchForm';
let memberUnionid = '1';
let qgyUrl = '';
let gameCookie = '';
let loginUrl = '';
let qgyTaskData = [];
let qgySignFlag = false;
let isTravelling = false;
let leftEnergyNum = 0;
let qgyProcess = '';
let greenFruitNum = 0;
let tokenStr = '';
let tokenKeyStr = '';
let qgyToken = '';
let isArticleReadFlag = false;
let articleReadList = [];
let taskBeforeScore = 0;
var timestamp = new Date().getTime();
var trandom = randomNum(1, 28);
let drawTimes = ''
let lessGameCount= 0;
let loveGame_recordId='';
let FKPHtml = ''
let downTime = 0
let pointRain_times = 0
let JFY_URL = ''
let FKP_URL = ''
let pointRain_startId = ''
let pointRain_activityStatus = true
let QGY_inviteCode = []
let AuthorinviteCode= ['IDTCLG','7LUL2L','BZZWJJ']
let AuthorCid = ['4116743840','4094106667','4093679412']
let QGY_canSteal = []
let TYT_URL = ''
let Jump_creditsCostId=''
let Jump_startId=''
let Jump_costResult = false
let Jump_PKstatus = false
console.log('✨✨✨ 口味王会员中心小程序签到✨✨✨\n' +
'✨ 功能:\n' +
' 积分签到\n' +
' 部分积分任务\n' +
'✨ 抓包步骤:\n' +
' 打开抓包工具\n' +
' 打开口味王会员中心小程序\n' +
' 授权登陆\n' +
' 找/member/api/info/的URl提取返回[memberId@unionid](@符号连接)\n' +
'参数示例:4249095xxxxxx@oWmTE6IqrlDFRzxxxxx\n' +
'✨ ✨✨wxpusher一对一推送功能,\n' +
' ✨需要定义变量export WXPUSHER=wxpusher的app_token,不设置则不启用wxpusher一对一推送\n' +
' ✨需要在KWW变量最后添加@wxpusher的UID\n' +
'✨ 设置青龙变量:\n' +
'export KWW=\'memberId@unionid@openid参数值\'多账号#或&分割\n' +
'export SCRIPT_UPDATE = \'False\' 关闭脚本自动更新,默认开启\n' +
'✨ 推荐cron:0 9 * * *\n' +
'✨✨✨ @Author CHERWIN✨✨✨')
//=======================================//
UserCookieArr = ENV_SPLIT(UserCookie)
!(async () => {
if (!(UserCookieArr)) {
console.log(`未定义${ENV_NAME}变量`)
process.exit();
} else {
// 版本检测
await getVersion();
Log(`\n 脚本执行✌北京时间(UTC+8):${new Date(new Date().getTime() + new Date().getTimezoneOffset() * 60 * 1000 + 8 * 60 * 60 * 1000).toLocaleString()} `)
console.log(`\n================ 共找到 【${UserCookieArr.length}】 个账号 ================ \n================ 版本对比检查更新 ================`);
if (await compareVersions(local_version, APP_CONFIG['NEW_VERSION'])){
Log(`\n 当前版本:${local_version}`)
Log(`\n 最新版本:${APP_CONFIG['NEW_VERSION']}`)
if (SCRIPT_UPDATE==true){
console.log('开始更新脚本')
const fileUrl = `https://github.com/CHERWING/CHERWIN_SCRIPTS/raw/main/${ENV_NAME}.js`;
const downloadPath = `./${ENV_NAME}.js`;
downloadFile(fileUrl, downloadPath)
}
}else{
console.log(`版本信息:${local_version} ,已是最新版本无需更新开始执行脚本`)
}
for (let index = 0; index < UserCookieArr.length; index++) {
one_msg = ''
let send_UID = ''
let num = index + 1
Log(`\n================ 开始第 【${num}】 个账号 -------->>>>>\n`)
// console.log(UserCookieArr[index])
if (num % 4 === 0) {
console.log('>>>>>>每4个账号等待60秒继续执行')
await $.wait(1000*60);
}
await $.wait(await delay());
let split_info = UserCookieArr[index].split("@")
memberId = split_info[0];
unionid = split_info[1];
let len_split_info = split_info.length
let last_info = split_info[len_split_info - 1]
// await DO_Jump()
taskBeforeScore = 0;
await start();
await $.wait(2000);
if (isArticleReadFlag) {
Log(`账号【${num}】: ❌ , 阅读失败,已经完成了`)
} else {
await readSubmit();
await $.wait(2000);
}
await $.wait(2000);
// await activeTaskFlag(2 * 1000)
await DO_QGY(num);
// await $.wait(2000);
// await DO_FKP();已结束
// await $.wait(5000);
// await DO_PointRain();已结束
await $.wait(5000);
//await DO_Jump();
//log(`\n==== 积分查询 ====\n`)
await getMemberScore();
console.log('\n====== 开始一对一推送 ======')
if (len_split_info > 0 && last_info.includes("UID_")) {
console.log(`>检测到设置了UID:【${last_info}】✅`);
send_UID = last_info
await send_wxpusher(send_UID,one_msg,APP_NAME);
}else{
Log('>未检测到wxpusher UID,不执行一对一推送❌')
}
await $.wait(3000);
}
// for (let index = 0; index < UserCookieArr.length; index++) {
// one_msg = ''
// let send_UID = ''
// let num = index + 1
// Log(`\n================ 开始第 【${num}】 个账号本地互助 -------->>>>>\n`)
// await $.wait(await delay());
// let split_info = UserCookieArr[index].split("@")
// memberId = split_info[0];
// unionid = split_info[1];
// let len_split_info = split_info.length
// let last_info = split_info[len_split_info - 1]
//
// await QGY_help(num)
// console.log('\n====== 开始一对一推送 ======')
// if (len_split_info > 0 && last_info.includes("UID_")) {
// console.log(`>检测到设置了UID:【${last_info}】✅`);
// send_UID = last_info
// await send_wxpusher(send_UID,one_msg,APP_NAME);
// }else{
// Log('>未检测到wxpusher UID,不执行一对一推送❌')
// }
// await $.wait(5000);
// }
Log(APP_CONFIG['GLOBAL_NTC'])
await SendMsg(msg);
}}
)()
.catch((e) => log(e))
.finally(() => $.done())
/**
* 获取基础信息
* @returns {Promise<boolean>}
*/
async function start() {
await getMemberInfo(2 * 1000);
await $.wait(2000);
await getMemberScore();
// await $.wait(2000);
// await getQgyUrl();
await $.wait(2000);
await getMrYdUrl();
await $.wait(2000);
// await getOtherUrl();
// await $.wait(2000);
await xxsBanner();
// await $.wait(2000);
// await getAnswerLists();
await $.wait(2000);
await selectTaskList();
return true;
}
/**
* 查询会员信息
* @param timeout
* @returns {Promise<unknown>}
*/
function getMemberInfo(timeout = 2000) {
return new Promise((resolve) => {
let url = {
url: `https://member.kwwblcj.com/member/api/info/?userKeys=${userKeys}&pageName=member-info-index-search&formName=${formName}&kwwMember.memberId=${memberId}&kwwMember.unionid=${unionid}&memberId=${memberId}`,
headers: {
Host: 'member.kwwblcj.com',
Connection: 'keep-alive',
'user-sign': getUserSign(memberId, timestamp, trandom).toLowerCase(),
'user-timestamp': timestamp,
'user-random': trandom,
'User-Agent': getUA(),
'content-type': 'application/json',
Referer: 'https://servicewechat.com/wxfb0905b0787971ad/58/page-frame.html'
},
}
$.get(url, async (error, response, data) => {
try {
let result = JSON.parse(data);
if (result.hasOwnProperty('flag') && result.flag == "T") {
userCname = result.result.memberInfo.userCname
memberUnionid = result.result.memberInfo.unionid
Log(`>登录成功✅`)
Log(`>用户名:【${userCname}】`)
} else {
Log(`>登录失败: ❌ ,原因是:${data}`)
}
} catch (e) {
console.log(`>查询会员信息异常❌:${data},原因:${e}`)
} finally {
resolve();
}
}, timeout)
})
}
/**
* 获取会员积分
* @returns {Promise<unknown>}
*/
async function getMemberScore(timeout = 2000) {
Log('====== 获取积分信息 ======')
return new Promise((resolve) => {
var options = {
method: 'GET',
url: 'https://member.kwwblcj.com/member/api/list/',
params: {
userKeys: userKeys,
pageName: 'select-member-score',
formName: formName,
memberId: memberId
},
headers: {
Host: 'member.kwwblcj.com',
Connection: 'keep-alive',
'user-sign': getUserSign(memberId, timestamp, trandom).toLowerCase(),
'user-timestamp': timestamp,
'user-random': trandom,
'User-Agent': getUA(),
'content-type': 'application/json',
'xweb_xhr': '1',
'user-paramname': 'memberId',
'Accept': '*/*',
'Sec-Fetch-Site': 'cross-site',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Dest': 'empty',
Referer: 'https://servicewechat.com/wxfb0905b0787971ad/58/page-frame.html'
},
};
axios.request(options).then(function (response) {
try {
var data = response.data;
if (data.hasOwnProperty('flag') && data.flag == "T") {
if (taskBeforeScore == 0) {
taskBeforeScore = data.rows;
Log(`>当前积分:${data.rows}`)
} else {
var calScore = parseInt(data.rows) - parseInt(taskBeforeScore);
// Log(`>\n获取积分信息成功✅`)
Log(`>执行后积分:${data.rows},本次获得【${calScore}】积分`)
}
} else {
console.log(`>查询积分失败❌,原因是:${data.msg}`)
}
} catch (e) {
log(`>查询积分失败异常:${data},原因:${e}`)
}
}).catch(function (error) {
console.error(1, error);
}).then(res => {
//这里处理正确返回
resolve();
}, timeout)
})
}
/**
* 查询任务列表
* @returns {Promise<unknown>}
*/
async function selectTaskList() {
console.log('====== 查询签到任务列表 ======')
return new Promise((resolve) => {
var options = {
method: 'GET',
url: 'https://member.kwwblcj.com/member/api/list/',
params: {
userKeys: userKeys,
pageName: 'select-task-list',
formName: formName,
memberId: memberId
},
headers: {
Host: 'member.kwwblcj.com',
Connection: 'keep-alive',
'user-sign': getUserSign(memberId, timestamp, trandom).toLowerCase(),
'user-timestamp': timestamp,
'user-random': trandom,
'User-Agent': getUA(),
'content-type': 'application/json',
Referer: 'https://servicewechat.com/wxfb0905b0787971ad/58/page-frame.html'
},
};
axios.request(options).then(function (response) {
try {
var data = response.data;
if (data.hasOwnProperty('flag') && data.flag == "T") {
for (var i in data.rows) {
var infoId = data.rows[i]['infoId'];
var ruleType = data.rows[i]['ruleType'];
var complete = data.rows[i]['complete'];
if (ruleType == "articleRead") {
isArticleReadFlag = (complete == 1) ? true : false;
}
}
console.log(`>获取任务列表成功✅`)
} else {
console.log(`>获取任务列表失败❌`)
console.log(`获取任务列表,原因是:${data.msg}`)
}
} catch (e) {
console.log(`获取任务列表异常:${data},原因:${e}`)
}
}).catch(function (error) {
console.error(1, error);
}).then(res => {
//这里处理正确返回
resolve();
});
})
}
/**
* 签到
* @returns {Promise<unknown>}
*/
async function signIn() {
return new Promise((resolve) => {
var options = {
method: 'POST',
url: 'https://member.kwwblcj.com/member/api/submit/',
params: {userKeys: userKeys},
headers: {
Host: 'member.kwwblcj.com',
Connection: 'keep-alive',
'user-sign': getUserSign(memberId, timestamp, trandom).toLowerCase(),
'user-timestamp': timestamp,
'user-random': trandom,
'content-type': 'application/json',
'User-Agent': getUA(),
Referer: 'https://servicewechat.com/wxfb0905b0787971ad/58/page-frame.html'
},
data: {
pageName: 'AddSignSvmInfo',
formName: 'addForm',
orderNo: signOrderNo,
paramNo: signParamNo,
cateId: signCateId,
memberId: memberId,
memberName: userCname
}
};
axios.request(options).then(function (response) {
var data = response.data;
if (data.hasOwnProperty('flag') && data.flag == "T") {
Log(`签到成功: ✅ ,${signRulesName}获得 ${signParamNo} 积分`)
} else {
Log(`签到失败: ❌ ,失败原因是:${data.msg}`)
}
}).catch(function (error) {
console.error(error);
}).then(res => {
//这里处理正确返回
resolve();
});
})
}
/**
* 获取资讯
* @returns {Promise<unknown>}
*/
async function xxsBanner() {
return new Promise((resolve) => {
var options = {
method: 'GET',
url: 'https://cms2.kwwblcj.com/data/xxsbanner2.json',
params: {T: timestampMs()},
headers: {
Host: 'cms.kwwblcj.com',
Connection: 'keep-alive',
'user-sign': getUserSign(memberId, timestamp, trandom).toLowerCase(),
'user-timestamp': timestamp,
'user-random': trandom,
'User-Agent': getUA(),
'content-type': 'application/json',
Referer: 'https://servicewechat.com/wxfb0905b0787971ad/34/page-frame.html',
}
};
axios.request(options).then(function (response) {
try {
var data = response.data;
articleReadList = data.rows;
log(`获取到${articleReadList.length}条资讯`)
} catch (e) {
console.log(`获取资讯信息异常❌:${data},原因:${e}`)
}
}).catch(function (error) {
console.error(error);
}).then(res => {
//这里处理正确返回
resolve();
});
})
}
/**
* 阅读信息
* @returns {Promise<unknown>}
*/
async function readInfo() {
return new Promise((resolve) => {
var options = {
method: 'GET',
url: 'https://qrcode.kwwblcj.com/qrc/api/info/' + unionid + '/',
params: {T: timestampMs(), memberId: memberId},
headers: {
Host: 'qrcode.kwwblcj.com',
Connection: 'keep-alive',
'User-Agent': getUA(),
'content-type': 'application/json',
Referer: 'https://servicewechat.com/wxfb0905b0787971ad/34/page-frame.html',
}
};
axios.request(options).then(function (response) {
try {
var data = response.data;
if (data.hasOwnProperty('flag') && data.flag == "T") {
console.log(`>查询阅读信息成功✅`)
} else {
console.log(`>查询阅读信息失败❌,原因是:${data.msg}`)
}
} catch (e) {
console.log(`>查询阅读信息异常❌:${data},原因:${e}`)
}
}).catch(function (error) {
console.error(error);
}).then(res => {
//这里处理正确返回
resolve();
});
})
}
/**
* 提交阅读
* @returns {Promise<unknown>}
*/
async function readSubmit() {
var max = articleReadList.length - 1;
var articleTitle = articleReadList[randomInt(0, max)]['title'];
return new Promise((resolve) => {
var options = {
method: 'GET',
url: 'https://member.kwwblcj.com/member/api/list/',
params: {
userKeys: userKeys,
pageName: 'setNewsReadTaskFlag',
formName: 'addForm',
memberId: memberId,
userCname: userCname,
articleTitle: articleTitle
},
headers: {
Host: 'member.kwwblcj.com',
Connection: 'keep-alive',
'user-sign': getUserSign(memberId, timestamp, trandom).toLowerCase(),
'user-timestamp': timestamp,
'user-random': trandom,
'User-Agent': getUA(),
'content-type': 'application/json',
Referer: 'https://servicewechat.com/wxfb0905b0787971ad/34/page-frame.html',
}
};
axios.request(options).then(function (response) {
try {
var data = response.data;
if (data.hasOwnProperty('flag') && data.flag == "T") {
Log(`每日阅读: 成功✅ ${data.rows}`)
} else {
Log(`每日阅读: 失败❌ 原因是:${data.msg}`)
}
} catch (e) {
console.log(`阅读信息异常❌:${data},原因:${e}`)
}
}).catch(function (error) {
console.error(error);
}).then(res => {
//这里处理正确返回
resolve();
});
})
}
async function activeTaskFlag(timeout = 2000) {
let options = {
url: `https://member.kwwblcj.com/member/api/list/?userKeys=${userKeys}&pageName=activeTaskFlag&formName=editForm&memberId=${memberId}&userCname=%7F%7F`,
headers: {
Host: 'member.kwwblcj.com',
Connection: 'keep-alive',
'user-sign': getUserSign(memberId, timestamp, trandom).toLowerCase(),
'user-timestamp': timestamp,
'user-random': trandom,
'content-type': 'application/json',
'User-Agent': getUA(),
Referer: 'https://servicewechat.com/wxfb0905b0787971ad/58/page-frame.html'
},
};
return new Promise((resolve) => {
$.get(options, async (error, response, data) => {
try {
let result = JSON.parse(data);
if (result.hasOwnProperty('flag') && result.flag == "T") {
console.log(`青果信息: 获取成功✅ 时间:${result.rows}`)
} else {
console.log(`青果信息: 失败❌原因是:${data}`)
}
} catch (e) {
console.log(`点击青果 异常❌:${data},原因:${e}`)
} finally {
resolve();
}
}, timeout)
})
}
/**
* 登入
* @param redirect
* @returns {Promise<unknown>}
*/
async function loginFreePlugin(redirect) {
return new Promise((resolve) => {
var options = {
method: 'GET',
url: 'https://member.kwwblcj.com/member/api/info/',
params: {
userKeys: userKeys,
pageName: 'loginFreePlugin',
formName: 'searchForm',
uid: memberId,
levelCode: '1',
redirect: redirect
},
headers: {
Host: 'member.kwwblcj.com',
Connection: 'keep-alive',
'user-sign': getUserSign(memberId, timestamp, trandom).toLowerCase(),
'user-timestamp': timestamp,
'user-random': trandom,
'content-type': 'application/json',
'User-Agent': getUA(),
Referer: 'https://servicewechat.com/wxfb0905b0787971ad/58/page-frame.html'
}
};
axios.request(options).then(function (response) {
try {
var data = response.data;
if (data.hasOwnProperty('flag') && data.flag == 'T') {
loginUrl = data.result;
Log(`>登入成功✅`)
}
} catch (e) {
console.log(`登入异常❌:${data},原因:${e}`)
}
}).catch(function (error) {
console.error(error);
}).then(res => {
//这里处理正确返回
resolve();
});
})
}
/**
* 设置cookie
* @returns {Promise<unknown>}
*/
async function setCookies() {
return new Promise((resolve) => {
var host = (loginUrl.split('//')[1]).split('/')[0];
try {
request(
{
url: loginUrl,
method: "GET",
headers: {
'Host': host,
'Connection': 'keep-alive',
'user-sign': getUserSign(memberId, timestamp, trandom).toLowerCase(),
'user-timestamp': timestamp,
'user-random': trandom,
'Upgrade-Insecure-Requests': '1',
'User-Agent': getUA(),
"Accept": 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
"Sec-Fetch-Site": "none",
"Sec-Fetch-Mode": "navigate",
"Sec-Fetch-User": "?1",
"Sec-Fetch-Dest": "document",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "en-us,en",
},
}, function (err, res, body) {
gameCookie = res.request.headers.cookie;
if (gameCookie){
console.log(`>转换Cookie成功!✅`)
}else{
console.log(`>转换Cookie失败!❌`)
}
})
} catch (e) {
console.log(e)
} finally {
resolve();
}
})
}
/**
* 完成青果园
* @param num
* @returns {Promise<boolean>}
*/
async function DO_QGY(num) {
console.log('\n--------------------开始嫩青果园活动----------------------')
qgyUrl = 'https://89420.activity-20.m.duiba.com.cn/projectx/p124e3402/index.html?appID=89420';
await loginFreePlugin(qgyUrl);
await $.wait(3000)
if (loginUrl == "") {
Log(`账号【${num}】登录青果园异常❌,自动跳过任务!`);
return false;
}
await setCookies();
await $.wait(3000);
if (gameCookie == "") {
Log(`账号【${num}】cookies异常❌,自动跳过任务!`);
return false;
}
var urlMatch = qgyUrl.match('([^/]+)/?$');
var baseUrl = qgyUrl.replace(urlMatch[0], '');
await getTokenKeyStr(baseUrl);
await $.wait(2000);
await getTokenStr(baseUrl);
qgyToken = dealToken(tokenStr, tokenKeyStr);
let isGuide = false
isGuide = await stepNewGuide(baseUrl, qgyToken)
while(isGuide == false){
await $.wait(2000);
await getTokenStr(baseUrl);
qgyToken = dealToken(tokenStr, tokenKeyStr);
await $.wait(2000);
isGuide = await stepNewGuide()
}
await $.wait(2000);
await getQgyInfo(baseUrl);
await getTokenStr(baseUrl);
await $.wait(2000);
await qgyCheckQuery(baseUrl);
await $.wait(2000);
if (qgySignFlag) {
Log(`>果园签到: 今天已经签到过了!✅`);
} else {
Log(`>今日未签到✅`);
try {
await getTokenStr(baseUrl);
await $.wait(2000);
qgyToken = dealToken(tokenStr, tokenKeyStr);
await $.wait(2000);
// await qgyCreateItem(baseUrl, qgyToken)
await $.wait(await delay());
await getTokenStr(baseUrl);
await $.wait(2000);
qgyToken = dealToken(tokenStr, tokenKeyStr);
await qgySign(baseUrl, qgyToken);
if(upNeedNum==null || upNeedNum==0){
await getTokenStr(baseUrl);
await $.wait(2000);
qgyToken = dealToken(tokenStr, tokenKeyStr);
await collectCoconut(baseUrl, qgyToken)
}
} catch (e) {
Log(`>账号【${num}】青果园签到异常!${e}`);
}
}
if (!isTravelling && greenFruitNum >= 20) {
try {
console.log(`>>>准备执行任务:【旅行】`);
await getTokenStr(baseUrl);
await $.wait(2000);
qgyToken = dealToken(tokenStr, tokenKeyStr);
await $.wait(2000);
await startTravel(baseUrl, qgyToken);
await $.wait(2000);
} catch (e) {
console.log(`>账号【${num}】青果园旅行异常❌!${e}`);
}
} else {
console.log(`>正在旅行中或青果不足20`);
}
await $.wait(2000);
await queryQgyTask(baseUrl);
await $.wait(2000);
if (qgyTaskData.length == 0) {
Log(`账号【${num}】获取青果园任务异常!❌`);
} else {
// console.log(qgyTaskData)
for (var i in qgyTaskData) {
// console.log(`>当前任务: 【${title}】`)
await $.wait(2000);
var id = qgyTaskData[i]["id"];
var taskCode = qgyTaskData[i]["code"];
var title = qgyTaskData[i]["title"];
var prizePendingCode = qgyTaskData[i]["prizePendingCode"];
var taskStatus = parseInt(qgyTaskData[i]["taskStatus"]);
if (taskStatus == 2) {
console.log(`>任务: 【${title}】已经完成了!✅`);
}else if(taskStatus == 1 && prizePendingCode){
console.log(`>任务: 【${title}】待领取!`);
await getTokenStr(baseUrl);
await $.wait(2000);
qgyToken = dealToken(tokenStr, tokenKeyStr);
await $.wait(2000);
await sendPrize(baseUrl,taskCode,prizePendingCode,title,qgyToken);
} else {
switch (id) {
case '1vp2qd9d':// 邀请好友参与种树
console.log(`>>>准备执行任务:【${title}】`);
await getTokenStr(baseUrl);
await $.wait(2000);
await get_QGY_InviteCode(baseUrl,dealToken(tokenStr, tokenKeyStr))
break;
case 'jnb9obsa':// 赠送好友能量
console.log(`>>>准备执行任务:【${title}】`);
for (var i=0;i<=AuthorCid.length;i++){
await getTokenStr(baseUrl);
await $.wait(2000);
await QGY_giveEnergy(baseUrl,dealToken(tokenStr, tokenKeyStr),AuthorCid[i-1])
}
break;
case '5re9y7rb':// 浏览资讯页
case '8pu8vs3s':// 参与海岛跳一跳
case 'm2jlv8yb':// 参与欢乐消除
case 'wk3mv0k9':// 参与美味连连看
case 'irigwir9':// 参与点卤大作战
//完成任务
console.log(`>>>准备执行任务:【${title}】`);
try {
await getTokenStr(baseUrl);
await $.wait(2000);
qgyToken = dealToken(tokenStr, tokenKeyStr);
await $.wait(2000);
prizePendingCode = await doCompleted(baseUrl, qgyToken, taskCode, title);
if (prizePendingCode != ''){
await getTokenStr(baseUrl);
await $.wait(2000);
qgyToken = dealToken(tokenStr, tokenKeyStr);
await $.wait(2000);
await sendPrize(baseUrl,taskCode,prizePendingCode,title,qgyToken);
}
} catch (e) {
console.log(`>任务:【${title}】异常❌!${e}`);
}
break;
default:
console.log(`>任务:【${title}】暂不支持,跳过!`)
break;
}
}
}
}
if (AuthorinviteCode){
for(var i = 1;i <= AuthorinviteCode.length;i++){
await $.wait(2000);
await getTokenStr(baseUrl);
qgyToken = dealToken(tokenStr, tokenKeyStr);
await $.wait(2000);
await qgyInviteAssist(baseUrl,qgyToken,AuthorinviteCode[i-1])
}
}
await getQgyInfo(baseUrl);
if (qgyProcess !== 'NaN%') {
if (leftEnergyNum > 0) {
var leftEnergyTimes = Math.ceil(leftEnergyNum / 20);;
console.log(`>可以加能量【${leftEnergyTimes}】次`);
for (var i = 1; i <= leftEnergyTimes; i++) {
console.log(`>>开始第 ${i} 次能量加速!`);
try {
await getTokenKeyStr(baseUrl);
await $.wait(2000);
await getTokenStr(baseUrl);
await $.wait(2000);
qgyToken = dealToken(tokenStr, tokenKeyStr);
await feed(baseUrl, qgyToken)
} catch (e) {
console.log(`>能量加速: 加速异常❌!${e}`);
}
}
} else {
console.log('>能量不足跳过加速❌')
}
} else {
console.log('>您还是先去种植把!❌')
}
await qgyFriendList(baseUrl)
if (QGY_canSteal.length >0){
for(var i=0;i<QGY_canSteal.length;i++){
await getTokenKeyStr(baseUrl);
await $.wait(2000);
await getTokenStr(baseUrl);
await $.wait(2000);
qgyToken = dealToken(tokenStr, tokenKeyStr);
var cid = QGY_canSteal[i]
await qgySteal(qgyToken,cid)
}
await $.wait(2000);
}
return true;
}
async function QGY_help(num){
console.log('\n====== 开始嫩青果园本地互助 ======')
qgyUrl = 'https://89420.activity-20.m.duiba.com.cn/projectx/p124e3402/index.html?appID=89420';
await loginFreePlugin(qgyUrl);
await $.wait(3000)
if (loginUrl == "") {
Log(`账号【${num}】登录青果园异常❌,自动跳过任务!`);
return false;
}
await setCookies();
await $.wait(3000);
if (gameCookie == "") {
Log(`账号【${num}】cookies异常❌,自动跳过任务!`);
return false;
}
var urlMatch = qgyUrl.match('([^/]+)/?$');
var baseUrl = qgyUrl.replace(urlMatch[0], '');
await getTokenKeyStr(baseUrl);
await $.wait(2000);
if (QGY_inviteCode){
console.log('当前全部邀请码:'+QGY_inviteCode)
for(var i = 1;i <= QGY_inviteCode.length;i++){
await $.wait(2000);
await getTokenStr(baseUrl);
qgyToken = dealToken(tokenStr, tokenKeyStr);
await $.wait(2000);
await qgyInviteAssist(baseUrl,qgyToken,QGY_inviteCode[i-1])
}
}
}
/**
* 获取token
* @param baseUrl
* @returns {Promise<unknown>}
*/
async function getTokenStr(baseUrl) {
return new Promise((resolve) => {
var url = baseUrl + 'getToken';
var host = (url.split('//')[1]).split('/')[0];
const options = {
method: 'GET',
url: url,
params: {_t: timestampMs()},
headers: {
cookie: gameCookie,
Host: host,
'user-sign': getUserSign(memberId, timestamp, trandom).toLowerCase(),
'user-timestamp': timestamp,
'user-random': trandom,
'Content-Type': 'application/x-www-form-urlencoded',
Connection: 'keep-alive',
Accept: '*/*',
'User-Agent': getUA(),
Referer: baseUrl + '/index.html?appID=89420&from=login&spm=89420.1.1.1',
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
'Accept-Encoding': 'gzip, deflate, br'
},
data: {}
};
axios.request(options).then(function (response) {
try {
tokenStr = response.data.data;
} catch (e) {
console.log(`获取任务: ❌ ,获取失败:${JSON.stringify(response.data)},原因:${e}`)
}
}).catch(function (error) {
console.error(error);
}).catch(function (error) {
console.error(error);
}).then(res => {
//这里处理正确返回
resolve();
});
})
}
/**
* 青果园签到检查
* @returns {Promise<unknown>}
*/
async function qgyCheckQuery(baseUrl) {
console.log('====== 查询青果园签到状态 ======')
qgySignFlag = false;
return new Promise((resolve) => {
var url = baseUrl + 'checkin_1/query.do';
var host = (url.split('//')[1]).split('/')[0];
var options = {
method: 'GET',
url: url,
params: {_t: timestampMs()},
headers: {
cookie: gameCookie,
Host: host,
'user-sign': getUserSign(memberId, timestamp, trandom).toLowerCase(),
'user-timestamp': timestamp,
'user-random': trandom,
'Content-Type': 'application/x-www-form-urlencoded',
Connection: 'keep-alive',
Accept: '*/*',
'User-Agent': getUA(),
Referer: qgyUrl + '&from=login&spm=89420.1.1.1',
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
},
data: {}