-
Notifications
You must be signed in to change notification settings - Fork 282
/
jd_fruit.js
1605 lines (1575 loc) · 78.3 KB
/
jd_fruit.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
/*
东东水果:脚本更新地址 https://gitee.com/lxk0301/jd_scripts/raw/master/jd_fruit.js
更新时间:2021-8-20
活动入口:京东APP我的-更多工具-东东农场
东东农场活动链接:https://h5.m.jd.com/babelDiy/Zeus/3KSjXqQabiTuD1cJ28QskrpWoBKT/index.html
已支持IOS双京东账号,Node.js支持N个京东账号
脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js
互助码shareCode请先手动运行脚本查看打印可看到
一天只能帮助3个人。多出的助力码无效
==========================Quantumultx=========================
[task_local]
#jd免费水果
5 6-18/6 * * * https://gitee.com/lxk0301/jd_scripts/raw/master/jd_fruit.js, tag=东东农场, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jdnc.png, enabled=true
=========================Loon=============================
[Script]
cron "5 6-18/6 * * *" script-path=https://gitee.com/lxk0301/jd_scripts/raw/master/jd_fruit.js,tag=东东农场
=========================Surge============================
东东农场 = type=cron,cronexp="5 6-18/6 * * *",wake-system=1,timeout=3600,script-path=https://gitee.com/lxk0301/jd_scripts/raw/master/jd_fruit.js
=========================小火箭===========================
东东农场 = type=cron,script-path=https://gitee.com/lxk0301/jd_scripts/raw/master/jd_fruit.js, cronexpr="5 6-18/6 * * *", timeout=3600, enable=true
jd免费水果 搬的https://github.com/liuxiaoyucc/jd-helper/blob/a6f275d9785748014fc6cca821e58427162e9336/fruit/fruit.js
*/
const $ = new Env('东东农场互助版');
let cookiesArr = [], cookie = '', isBox = false, notify,allMessage = '';
//助力好友分享码(最多3个,否则后面的助力失败),原因:京东农场每人每天只有3次助力机会
//此此内容是IOS用户下载脚本到本地使用,填写互助码的地方,同一京东账号的好友互助码请使用@符号隔开。
//下面给出两个账号的填写示例(iOS只支持2个京东账号)
let newShareCodes=[];
let message = '', subTitle = '', option = {}, isFruitFinished = false;
const retainWater = $.isNode() ? (process.env.retainWater ? process.env.retainWater : 100) : ($.getdata('retainWater') ? $.getdata('retainWater') : 100);//保留水滴大于多少g,默认100g;
let jdNotify = false;//是否关闭通知,false打开通知推送,true关闭通知推送
let jdFruitBeanCard = false;//农场使用水滴换豆卡(如果出现限时活动时100g水换20豆,此时比浇水划算,推荐换豆),true表示换豆(不浇水),false表示不换豆(继续浇水),脚本默认是浇水
const JD_API_HOST = 'https://api.m.jd.com/client.action';
const urlSchema = `openjd://virtual?params=%7B%20%22category%22:%20%22jump%22,%20%22des%22:%20%22m%22,%20%22url%22:%20%22https://h5.m.jd.com/babelDiy/Zeus/3KSjXqQabiTuD1cJ28QskrpWoBKT/index.html%22%20%7D`;
let NowHour = new Date().getHours();
let llhelp=true;
if ($.isNode() && process.env.CC_NOHELPAFTER8) {
if (process.env.CC_NOHELPAFTER8=="true"){
if (NowHour>8){
llhelp=false;
console.log(`现在是9点后时段,不启用互助....`);
}
}
}
const fs = require('fs');
let boolneedUpdate=false;
let strShare = './Fruit_ShareCache.json';
let Fileexists = fs.existsSync(strShare);
let TempShareCache = [];
if (Fileexists) {
console.log("检测到东东农场缓存文件Fruit_ShareCache.json,载入...");
TempShareCache = fs.readFileSync(strShare, 'utf-8');
if (TempShareCache) {
TempShareCache = TempShareCache.toString();
TempShareCache = JSON.parse(TempShareCache);
}
}
let WP_APP_TOKEN_ONE = "";
/* if ($.isNode()) {
if (process.env.WP_APP_TOKEN_ONE) {
WP_APP_TOKEN_ONE = process.env.WP_APP_TOKEN_ONE;
}
}
if (WP_APP_TOKEN_ONE) {
console.log(`检测到已配置Wxpusher的Token,启用一对一推送...`);
if (NowHour <9 || NowHour > 21) {
WP_APP_TOKEN_ONE = "";
console.log(`农场只在9点后和22点前启用一对一推送,故此次暂时取消一对一推送...`);
}
} else
console.log(`检测到未配置Wxpusher的Token,禁用一对一推送...`); */
let lnrun=0;
let llgetshare=false;
let NoNeedCodes = [];
!(async () => {
await requireConfig();
if (!cookiesArr[0]) {
$.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', { "open-url": "https://bean.m.jd.com/bean/signIndex.action" });
return;
}
if (llhelp) {
console.log('开始收集您的互助码,用于账号内部互助,请稍等...');
for (let i = 0; i < cookiesArr.length; i++) {
if (cookiesArr[i]) {
cookie = cookiesArr[i];
$.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]);
$.index = i + 1;
$.isLogin = true;
$.nickName = '';
await TotalBean();
if (!$.isLogin) {
$.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, {
"open-url": "https://bean.m.jd.com/bean/signIndex.action"
});
if ($.isNode()) {
await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`);
}
continue
}
message = '';
subTitle = '';
option = {};
$.retry = 0;
llgetshare=false;
await GetCollect();
if(llgetshare){
await $.wait(5000);
lnrun++;
}
if(lnrun==10){
console.log(`访问接口次数达到10次,休息一分钟.....`);
await $.wait(60*1000);
lnrun=0;
}
}
}
if (boolneedUpdate) {
var str = JSON.stringify(TempShareCache, null, 2);
fs.writeFile(strShare, str, function (err) {
if (err) {
console.log(err);
console.log("缓存文件Fruit_ShareCache.json更新失败!");
} else {
console.log("缓存文件Fruit_ShareCache.json更新成功!");
}
})
}
}
for (let i = 0; i < cookiesArr.length; i++) {
if (cookiesArr[i]) {
cookie = cookiesArr[i];
$.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]);
$.index = i + 1;
$.isLogin = true;
$.nickName = '';
await TotalBean();
console.log(`\n开始【京东账号${$.index}】${$.nickName || $.UserName}\n`);
if (!$.isLogin) {
$.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, {
"open-url": "https://bean.m.jd.com/bean/signIndex.action"
});
if ($.isNode()) {
await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`);
}
continue
}
message = '';
subTitle = '';
option = {};
$.retry = 0;
lnrun++;
await jdFruit();
if (lnrun == 5) {
console.log(`访问接口次数达到5次,休息一分钟.....`);
await $.wait(60 * 1000);
lnrun = 0;
}
}
}
if ($.isNode() && allMessage && $.ctrTemp) {
await notify.sendNotify(`${$.name}`, `${allMessage}`)
}
})()
.catch((e) => {
$.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '')
})
.finally(() => {
$.done();
})
async function jdFruit() {
subTitle = `【京东账号${$.index}】${$.nickName || $.UserName}`;
try {
await initForFarm();
if ($.farmInfo.farmUserPro) {
message = `【水果名称】${$.farmInfo.farmUserPro.name}\n`;
console.log(`\n【已成功兑换水果】${$.farmInfo.farmUserPro.winTimes}次\n`);
message += `【已兑换水果】${$.farmInfo.farmUserPro.winTimes}次\n`;
await masterHelpShare();//助力好友
if ($.farmInfo.treeState === 2 || $.farmInfo.treeState === 3) {
option['open-url'] = urlSchema;
$.msg($.name, ``, `【京东账号${$.index}】${$.nickName || $.UserName}\n【提醒⏰】${$.farmInfo.farmUserPro.name}已可领取\n请去京东APP或微信小程序查看\n点击弹窗即达`, option);
if ($.isNode()) {
await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName || $.UserName}水果已可领取`, `【京东账号${$.index}】${$.nickName || $.UserName}\n【提醒⏰】${$.farmInfo.farmUserPro.name}已可领取\n请去京东APP或微信小程序查看`);
}
if ($.isNode() && WP_APP_TOKEN_ONE) {
await notify.sendNotifybyWxPucher($.name, `【京东账号】${$.nickName || $.UserName}\n【提醒⏰】${$.farmInfo.farmUserPro.name}已可领取\n【领取步骤】京东->我的->东东农场兑换京东红包,可以用于京东app的任意商品.`, `${$.UserName}`);
}
return
} else if ($.farmInfo.treeState === 1) {
console.log(`\n${$.farmInfo.farmUserPro.name}种植中...\n`)
} else if ($.farmInfo.treeState === 0) {
//已下单购买, 但未开始种植新的水果
option['open-url'] = urlSchema;
$.msg($.name, ``, `【京东账号${$.index}】 ${$.nickName || $.UserName}\n【提醒⏰】您忘了种植新的水果\n请去京东APP或微信小程序选购并种植新的水果\n点击弹窗即达`, option);
if ($.isNode()) {
await notify.sendNotify(`${$.name} - 您忘了种植新的水果`, `京东账号${$.index} ${$.nickName || $.UserName}\n【提醒⏰】您忘了种植新的水果\n请去京东APP或微信小程序选购并种植新的水果`);
}
return
}
await doDailyTask();
await doTenWater();//浇水十次
await getFirstWaterAward();//领取首次浇水奖励
await getTenWaterAward();//领取10浇水奖励
await getWaterFriendGotAward();//领取为2好友浇水奖励
await duck();
await doTenWaterAgain();//再次浇水
await predictionFruit();//预测水果成熟时间
} else {
console.log(`初始化农场数据异常, 请登录京东 app查看农场功能是否正常`);
message+=`初始化农场数据异常, 请登录京东 app查看农场功能是否正常`;
}
} catch (e) {
console.log(`任务执行异常,请检查执行日志 ‼️‼️`);
$.logErr(e);
const errMsg = `京东账号${$.index} ${$.nickName || $.UserName}\n任务执行异常,请检查执行日志 ‼️‼️`;
if ($.isNode()) await notify.sendNotify(`${$.name}`, errMsg);
$.msg($.name, '', `${errMsg}`)
}
await showMsg();
}
async function doDailyTask() {
await taskInitForFarm();
console.log(`开始签到`);
if (!$.farmTask.signInit.todaySigned) {
await signForFarm(); //签到
if ($.signResult.code === "0") {
console.log(`【签到成功】获得${$.signResult.amount}g💧\\n`)
//message += `【签到成功】获得${$.signResult.amount}g💧\n`//连续签到${signResult.signDay}天
} else {
// message += `签到失败,详询日志\n`;
console.log(`签到结果: ${JSON.stringify($.signResult)}`);
}
} else {
console.log(`今天已签到,连续签到${$.farmTask.signInit.totalSigned},下次签到可得${$.farmTask.signInit.signEnergyEachAmount}g\n`);
}
// 被水滴砸中
console.log(`被水滴砸中: ${$.farmInfo.todayGotWaterGoalTask.canPop ? '是' : '否'}`);
if ($.farmInfo.todayGotWaterGoalTask.canPop) {
await gotWaterGoalTaskForFarm();
if ($.goalResult.code === '0') {
console.log(`【被水滴砸中】获得${$.goalResult.addEnergy}g💧\\n`);
// message += `【被水滴砸中】获得${$.goalResult.addEnergy}g💧\n`
}
}
console.log(`签到结束,开始广告浏览任务`);
if ($.farmTask.gotBrowseTaskAdInit.f) {
console.log(`今天已经做过浏览广告任务\n`);
} else {
let adverts = $.farmTask.gotBrowseTaskAdInit.userBrowseTaskAds
let browseReward = 0
let browseSuccess = 0
let browseFail = 0
for (let advert of adverts) { //开始浏览广告
if (advert.limit <= advert.hadFinishedTimes) {
// browseReward+=advert.reward
console.log(`${advert.mainTitle}+ ' 已完成`);//,获得${advert.reward}g
continue;
}
console.log('正在进行广告浏览任务: ' + advert.mainTitle);
await browseAdTaskForFarm(advert.advertId, 0);
if ($.browseResult.code === '0') {
console.log(`${advert.mainTitle}浏览任务完成`);
//领取奖励
await browseAdTaskForFarm(advert.advertId, 1);
if ($.browseRwardResult.code === '0') {
console.log(`领取浏览${advert.mainTitle}广告奖励成功,获得${$.browseRwardResult.amount}g`)
browseReward += $.browseRwardResult.amount
browseSuccess++
} else {
browseFail++
console.log(`领取浏览广告奖励结果: ${JSON.stringify($.browseRwardResult)}`)
}
} else {
browseFail++
console.log(`广告浏览任务结果: ${JSON.stringify($.browseResult)}`);
}
}
if (browseFail > 0) {
console.log(`【广告浏览】完成${browseSuccess}个,失败${browseFail},获得${browseReward}g💧\\n`);
// message += `【广告浏览】完成${browseSuccess}个,失败${browseFail},获得${browseReward}g💧\n`;
} else {
console.log(`【广告浏览】完成${browseSuccess}个,获得${browseReward}g💧\n`);
// message += `【广告浏览】完成${browseSuccess}个,获得${browseReward}g💧\n`;
}
}
//定时领水
if (!$.farmTask.gotThreeMealInit.f) {
//
await gotThreeMealForFarm();
if ($.threeMeal.code === "0") {
console.log(`【定时领水】获得${$.threeMeal.amount}g💧\n`);
// message += `【定时领水】获得${$.threeMeal.amount}g💧\n`;
} else {
// message += `【定时领水】失败,详询日志\n`;
console.log(`定时领水成功结果: ${JSON.stringify($.threeMeal)}`);
}
} else {
console.log('当前不在定时领水时间断或者已经领过\n')
}
//给好友浇水
if (!$.farmTask.waterFriendTaskInit.f) {
if ($.farmTask.waterFriendTaskInit.waterFriendCountKey < $.farmTask.waterFriendTaskInit.waterFriendMax) {
await doFriendsWater();
}
} else {
console.log(`给${$.farmTask.waterFriendTaskInit.waterFriendMax}个好友浇水任务已完成\n`)
}
await getAwardInviteFriend();
await clockInIn();//打卡领水
await executeWaterRains();//水滴雨
await getExtraAward();//领取额外水滴奖励
await turntableFarm()//天天抽奖得好礼
}
async function predictionFruit() {
console.log('开始预测水果成熟时间\n');
await initForFarm();
await taskInitForFarm();
let waterEveryDayT = $.farmTask.totalWaterTaskInit.totalWaterTaskTimes;//今天到到目前为止,浇了多少次水
message += `【今日共浇水】${waterEveryDayT}次\n`;
message += `【剩余 水滴】${$.farmInfo.farmUserPro.totalEnergy}g💧\n`;
message += `【水果🍉进度】${(($.farmInfo.farmUserPro.treeEnergy / $.farmInfo.farmUserPro.treeTotalEnergy) * 100).toFixed(2)}%,已浇水${$.farmInfo.farmUserPro.treeEnergy / 10}次,还需${($.farmInfo.farmUserPro.treeTotalEnergy - $.farmInfo.farmUserPro.treeEnergy) / 10}次\n`
if ($.farmInfo.toFlowTimes > ($.farmInfo.farmUserPro.treeEnergy / 10)) {
message += `【开花进度】再浇水${$.farmInfo.toFlowTimes - $.farmInfo.farmUserPro.treeEnergy / 10}次开花\n`
} else if ($.farmInfo.toFruitTimes > ($.farmInfo.farmUserPro.treeEnergy / 10)) {
message += `【结果进度】再浇水${$.farmInfo.toFruitTimes - $.farmInfo.farmUserPro.treeEnergy / 10}次结果\n`
}
// 预测n天后水果课可兑换功能
let waterTotalT = ($.farmInfo.farmUserPro.treeTotalEnergy - $.farmInfo.farmUserPro.treeEnergy - $.farmInfo.farmUserPro.totalEnergy) / 10;//一共还需浇多少次水
let waterD = Math.ceil(waterTotalT / waterEveryDayT);
message += `【预测】${waterD === 1 ? '明天' : waterD === 2 ? '后天' : waterD + '天之后'}(${timeFormat(24 * 60 * 60 * 1000 * waterD + Date.now())}日)可兑换水果🍉`
}
//浇水十次
async function doTenWater() {
try {
jdFruitBeanCard = $.getdata('jdFruitBeanCard') ? $.getdata('jdFruitBeanCard') : jdFruitBeanCard;
if ($.isNode() && process.env.FRUIT_BEAN_CARD) {
jdFruitBeanCard = process.env.FRUIT_BEAN_CARD;
}
await myCardInfoForFarm();
const {
fastCard,
doubleCard,
beanCard,
signCard
} = $.myCardInfoRes;
/* if (`${jdFruitBeanCard}` === 'true' && JSON.stringify($.myCardInfoRes).match(`限时翻倍`) && beanCard > 0) {
console.log(`您设置的是使用水滴换豆卡,且背包有水滴换豆卡${beanCard}张, 跳过10次浇水任务`)
return
} */
if ($.farmTask.totalWaterTaskInit.totalWaterTaskTimes < $.farmTask.totalWaterTaskInit.totalWaterTaskLimit) {
console.log(`\n准备浇水十次`);
let waterCount = 0;
isFruitFinished = false;
for (; waterCount < $.farmTask.totalWaterTaskInit.totalWaterTaskLimit - $.farmTask.totalWaterTaskInit.totalWaterTaskTimes; waterCount++) {
console.log(`第${waterCount + 1}次浇水`);
await waterGoodForFarm();
console.log(`本次浇水结果: ${JSON.stringify($.waterResult)}`);
if ($.waterResult.code === '0') {
console.log(`剩余水滴${$.waterResult.totalEnergy}g`);
if ($.waterResult.finished) {
// 已证实,waterResult.finished为true,表示水果可以去领取兑换了
isFruitFinished = true;
break
} else {
if ($.waterResult.totalEnergy < 10) {
console.log(`水滴不够,结束浇水`)
break
}
await gotStageAward(); //领取阶段性水滴奖励
}
} else {
console.log('浇水出现失败异常,跳出不在继续浇水')
break;
}
}
if (isFruitFinished) {
option['open-url'] = urlSchema;
$.msg($.name, ``, `【京东账号${$.index}】${$.nickName || $.UserName}\n【提醒⏰】${$.farmInfo.farmUserPro.name}已可领取\n请去京东APP或微信小程序查看\n点击弹窗即达`, option);
$.done();
if ($.isNode()) {
await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName || $.UserName}水果已可领取`, `京东账号${$.index} ${$.nickName || $.UserName}\n${$.farmInfo.farmUserPro.name}已可领取`);
}
if ($.isNode() && WP_APP_TOKEN_ONE) {
await notify.sendNotifybyWxPucher($.name, `【京东账号】${$.nickName || $.UserName}\n【提醒⏰】${$.farmInfo.farmUserPro.name}已可领取\n【领取步骤】京东->我的->东东农场兑换京东红包,可以用于京东app的任意商品.`, `${$.UserName}`);
}
}
} else {
console.log('\n今日已完成10次浇水任务\n');
}
} catch (e) {
console.log(`doTenWater 任务执行异常‼️‼️`);
$.logErr(e);
}
}
//领取首次浇水奖励
async function getFirstWaterAward() {
await taskInitForFarm();
//领取首次浇水奖励
if (!$.farmTask.firstWaterInit.f && $.farmTask.firstWaterInit.totalWaterTimes > 0) {
await firstWaterTaskForFarm();
if ($.firstWaterReward.code === '0') {
console.log(`【首次浇水奖励】获得${$.firstWaterReward.amount}g💧\n`);
// message += `【首次浇水奖励】获得${$.firstWaterReward.amount}g💧\n`;
} else {
// message += '【首次浇水奖励】领取奖励失败,详询日志\n';
console.log(`领取首次浇水奖励结果: ${JSON.stringify($.firstWaterReward)}`);
}
} else {
console.log('首次浇水奖励已领取\n')
}
}
//领取十次浇水奖励
async function getTenWaterAward() {
//领取10次浇水奖励
if (!$.farmTask.totalWaterTaskInit.f && $.farmTask.totalWaterTaskInit.totalWaterTaskTimes >= $.farmTask.totalWaterTaskInit.totalWaterTaskLimit) {
await totalWaterTaskForFarm();
if ($.totalWaterReward.code === '0') {
console.log(`【十次浇水奖励】获得${$.totalWaterReward.totalWaterTaskEnergy}g💧\n`);
// message += `【十次浇水奖励】获得${$.totalWaterReward.totalWaterTaskEnergy}g💧\n`;
} else {
// message += '【十次浇水奖励】领取奖励失败,详询日志\n';
console.log(`领取10次浇水奖励结果: ${JSON.stringify($.totalWaterReward)}`);
}
} else if ($.farmTask.totalWaterTaskInit.totalWaterTaskTimes < $.farmTask.totalWaterTaskInit.totalWaterTaskLimit) {
// message += `【十次浇水奖励】任务未完成,今日浇水${$.farmTask.totalWaterTaskInit.totalWaterTaskTimes}次\n`;
console.log(`【十次浇水奖励】任务未完成,今日浇水${$.farmTask.totalWaterTaskInit.totalWaterTaskTimes}次\n`);
}
console.log('finished 水果任务完成!');
}
//再次浇水
async function doTenWaterAgain() {
console.log('开始检查剩余水滴能否再次浇水再次浇水\n');
await initForFarm();
let totalEnergy = $.farmInfo.farmUserPro.totalEnergy;
console.log(`剩余水滴${totalEnergy}g\n`);
await myCardInfoForFarm();
const { fastCard, doubleCard, beanCard, signCard } = $.myCardInfoRes;
console.log(`背包已有道具:\n快速浇水卡:${fastCard === -1 ? '未解锁' : fastCard + '张'}\n水滴翻倍卡:${doubleCard === -1 ? '未解锁' : doubleCard + '张'}\n水滴换京豆卡:${beanCard === -1 ? '未解锁' : beanCard + '张'}\n加签卡:${signCard === -1 ? '未解锁' : signCard + '张'}\n`)
if (totalEnergy >= 100 && doubleCard > 0) {
//使用翻倍水滴卡
for (let i = 0; i < new Array(doubleCard).fill('').length; i++) {
await userMyCardForFarm('doubleCard');
console.log(`使用翻倍水滴卡结果:${JSON.stringify($.userMyCardRes)}`);
}
await initForFarm();
totalEnergy = $.farmInfo.farmUserPro.totalEnergy;
}
if (signCard > 0) {
//使用加签卡
for (let i = 0; i < new Array(signCard).fill('').length; i++) {
await userMyCardForFarm('signCard');
console.log(`使用加签卡结果:${JSON.stringify($.userMyCardRes)}`);
}
await initForFarm();
totalEnergy = $.farmInfo.farmUserPro.totalEnergy;
}
jdFruitBeanCard = $.getdata('jdFruitBeanCard') ? $.getdata('jdFruitBeanCard') : jdFruitBeanCard;
if ($.isNode() && process.env.FRUIT_BEAN_CARD) {
jdFruitBeanCard = process.env.FRUIT_BEAN_CARD;
}
if (`${jdFruitBeanCard}` === 'true' && JSON.stringify($.myCardInfoRes).match('限时翻倍')) {
console.log(`\n您设置的是水滴换豆功能,现在为您换豆`);
for (let lncount = 0; lncount < $.myCardInfoRes.beanCard; lncount++) {
if (totalEnergy >= 150 && $.myCardInfoRes.beanCard > 0) {
//使用水滴换豆卡
await userMyCardForFarm('beanCard');
console.log(`使用水滴换豆卡结果:${JSON.stringify($.userMyCardRes)}`);
if ($.userMyCardRes.code === '0') {
totalEnergy=totalEnergy-100;
message += `【水滴换豆卡】获得${$.userMyCardRes.beanCount}个京豆\n`;
}
} else {
console.log(`您目前水滴:${totalEnergy}g,水滴换豆卡${$.myCardInfoRes.beanCard}张,暂不满足水滴换豆的条件,为您继续浇水`)
break;
}
}
return;
}
// if (totalEnergy > 100 && $.myCardInfoRes.fastCard > 0) {
// //使用快速浇水卡
// await userMyCardForFarm('fastCard');
// console.log(`使用快速浇水卡结果:${JSON.stringify($.userMyCardRes)}`);
// if ($.userMyCardRes.code === '0') {
// console.log(`已使用快速浇水卡浇水${$.userMyCardRes.waterEnergy}g`);
// }
// await initForFarm();
// totalEnergy = $.farmInfo.farmUserPro.totalEnergy;
// }
// 所有的浇水(10次浇水)任务,获取水滴任务完成后,如果剩余水滴大于等于60g,则继续浇水(保留部分水滴是用于完成第二天的浇水10次的任务)
let overageEnergy = totalEnergy - retainWater;
if (totalEnergy >= ($.farmInfo.farmUserPro.treeTotalEnergy - $.farmInfo.farmUserPro.treeEnergy)) {
//如果现有的水滴,大于水果可兑换所需的对滴(也就是把水滴浇完,水果就能兑换了)
isFruitFinished = false;
for (let i = 0; i < ($.farmInfo.farmUserPro.treeTotalEnergy - $.farmInfo.farmUserPro.treeEnergy) / 10; i++) {
await waterGoodForFarm();
console.log(`本次浇水结果(水果马上就可兑换了): ${JSON.stringify($.waterResult)}`);
if ($.waterResult.code === '0') {
console.log('\n浇水10g成功\n');
if ($.waterResult.finished) {
// 已证实,waterResult.finished为true,表示水果可以去领取兑换了
isFruitFinished = true;
break
} else {
console.log(`目前水滴【${$.waterResult.totalEnergy}】g,继续浇水,水果马上就可以兑换了`)
}
} else {
console.log('浇水出现失败异常,跳出不在继续浇水')
break;
}
}
if (isFruitFinished) {
option['open-url'] = urlSchema;
$.msg($.name, ``, `【京东账号${$.index}】${$.nickName || $.UserName}\n【提醒⏰】${$.farmInfo.farmUserPro.name}已可领取\n请去京东APP或微信小程序查看\n点击弹窗即达`, option);
$.done();
if ($.isNode()) {
await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName || $.UserName}水果已可领取`, `京东账号${$.index} ${$.nickName || $.UserName}\n${$.farmInfo.farmUserPro.name}已可领取`);
}
if ($.isNode() && WP_APP_TOKEN_ONE) {
await notify.sendNotifybyWxPucher($.name, `【京东账号】${$.nickName || $.UserName}\n【提醒⏰】${$.farmInfo.farmUserPro.name}已可领取\n【领取步骤】京东->我的->东东农场兑换京东红包,可以用于京东app的任意商品.`, `${$.UserName}`);
}
}
} else if (overageEnergy >= 10) {
console.log("目前剩余水滴:【" + totalEnergy + "】g,可继续浇水");
isFruitFinished = false;
for (let i = 0; i < parseInt(overageEnergy / 10); i++) {
await waterGoodForFarm();
console.log(`本次浇水结果: ${JSON.stringify($.waterResult)}`);
if ($.waterResult.code === '0') {
console.log(`\n浇水10g成功,剩余${$.waterResult.totalEnergy}\n`)
if ($.waterResult.finished) {
// 已证实,waterResult.finished为true,表示水果可以去领取兑换了
isFruitFinished = true;
break
} else {
await gotStageAward()
}
} else {
console.log('浇水出现失败异常,跳出不在继续浇水')
break;
}
}
if (isFruitFinished) {
option['open-url'] = urlSchema;
$.msg($.name, ``, `【京东账号${$.index}】${$.nickName || $.UserName}\n【提醒⏰】${$.farmInfo.farmUserPro.name}已可领取\n请去京东APP或微信小程序查看\n点击弹窗即达`, option);
$.done();
if ($.isNode()) {
await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName || $.UserName}水果已可领取`, `京东账号${$.index} ${$.nickName || $.UserName}\n${$.farmInfo.farmUserPro.name}已可领取`);
}
if ($.isNode() && WP_APP_TOKEN_ONE) {
await notify.sendNotifybyWxPucher($.name, `【京东账号】${$.nickName || $.UserName}\n【提醒⏰】${$.farmInfo.farmUserPro.name}已可领取\n【领取步骤】京东->我的->东东农场兑换京东红包,可以用于京东app的任意商品.`, `${$.UserName}`);
}
}
} else {
console.log("目前剩余水滴:【" + totalEnergy + "】g,不再继续浇水,保留部分水滴用于完成第二天【十次浇水得水滴】任务")
}
}
//领取阶段性水滴奖励
function gotStageAward() {
return new Promise(async resolve => {
if ($.waterResult.waterStatus === 0 && $.waterResult.treeEnergy === 10) {
console.log('果树发芽了,奖励30g水滴');
await gotStageAwardForFarm('1');
console.log(`浇水阶段奖励1领取结果 ${JSON.stringify($.gotStageAwardForFarmRes)}`);
if ($.gotStageAwardForFarmRes.code === '0') {
// message += `【果树发芽了】奖励${$.gotStageAwardForFarmRes.addEnergy}\n`;
console.log(`【果树发芽了】奖励${$.gotStageAwardForFarmRes.addEnergy}\n`);
}
} else if ($.waterResult.waterStatus === 1) {
console.log('果树开花了,奖励40g水滴');
await gotStageAwardForFarm('2');
console.log(`浇水阶段奖励2领取结果 ${JSON.stringify($.gotStageAwardForFarmRes)}`);
if ($.gotStageAwardForFarmRes.code === '0') {
// message += `【果树开花了】奖励${$.gotStageAwardForFarmRes.addEnergy}g💧\n`;
console.log(`【果树开花了】奖励${$.gotStageAwardForFarmRes.addEnergy}g💧\n`);
}
} else if ($.waterResult.waterStatus === 2) {
console.log('果树长出小果子啦, 奖励50g水滴');
await gotStageAwardForFarm('3');
console.log(`浇水阶段奖励3领取结果 ${JSON.stringify($.gotStageAwardForFarmRes)}`)
if ($.gotStageAwardForFarmRes.code === '0') {
// message += `【果树结果了】奖励${$.gotStageAwardForFarmRes.addEnergy}g💧\n`;
console.log(`【果树结果了】奖励${$.gotStageAwardForFarmRes.addEnergy}g💧\n`);
}
}
resolve()
})
}
//天天抽奖活动
async function turntableFarm() {
await initForTurntableFarm();
if ($.initForTurntableFarmRes.code === '0') {
//领取定时奖励 //4小时一次
let { timingIntervalHours, timingLastSysTime, sysTime, timingGotStatus, remainLotteryTimes, turntableInfos } = $.initForTurntableFarmRes;
if (!timingGotStatus) {
console.log(`是否到了领取免费赠送的抽奖机会----${sysTime > (timingLastSysTime + 60 * 60 * timingIntervalHours * 1000)}`)
if (sysTime > (timingLastSysTime + 60 * 60 * timingIntervalHours * 1000)) {
await timingAwardForTurntableFarm();
console.log(`领取定时奖励结果${JSON.stringify($.timingAwardRes)}`);
await initForTurntableFarm();
remainLotteryTimes = $.initForTurntableFarmRes.remainLotteryTimes;
} else {
console.log(`免费赠送的抽奖机会未到时间`)
}
} else {
console.log('4小时候免费赠送的抽奖机会已领取')
}
if ($.initForTurntableFarmRes.turntableBrowserAds && $.initForTurntableFarmRes.turntableBrowserAds.length > 0) {
for (let index = 0; index < $.initForTurntableFarmRes.turntableBrowserAds.length; index++) {
if (!$.initForTurntableFarmRes.turntableBrowserAds[index].status) {
console.log(`开始浏览天天抽奖的第${index + 1}个逛会场任务`)
await browserForTurntableFarm(1, $.initForTurntableFarmRes.turntableBrowserAds[index].adId);
if ($.browserForTurntableFarmRes.code === '0' && $.browserForTurntableFarmRes.status) {
console.log(`第${index + 1}个逛会场任务完成,开始领取水滴奖励\n`)
await browserForTurntableFarm(2, $.initForTurntableFarmRes.turntableBrowserAds[index].adId);
if ($.browserForTurntableFarmRes.code === '0') {
console.log(`第${index + 1}个逛会场任务领取水滴奖励完成\n`)
await initForTurntableFarm();
remainLotteryTimes = $.initForTurntableFarmRes.remainLotteryTimes;
}
}
} else {
console.log(`浏览天天抽奖的第${index + 1}个逛会场任务已完成`)
}
}
}
//天天抽奖助力
console.log('开始天天抽奖--好友助力--每人每天只有三次助力机会.')
for (let code of newShareCodes) {
if (code === $.farmInfo.farmUserPro.shareCode) {
console.log('天天抽奖-不能自己给自己助力\n')
continue
}
await lotteryMasterHelp(code);
// console.log('天天抽奖助力结果',lotteryMasterHelpRes.helpResult)
if ($.lotteryMasterHelpRes.helpResult.code === '0') {
console.log(`天天抽奖-助力${$.lotteryMasterHelpRes.helpResult.masterUserInfo.nickName}成功\n`)
} else if ($.lotteryMasterHelpRes.helpResult.code === '11') {
console.log(`天天抽奖-不要重复助力${$.lotteryMasterHelpRes.helpResult.masterUserInfo.nickName}\n`)
} else if ($.lotteryMasterHelpRes.helpResult.code === '13') {
console.log(`天天抽奖-助力${$.lotteryMasterHelpRes.helpResult.masterUserInfo.nickName}失败,助力次数耗尽\n`);
break;
}
}
console.log(`---天天抽奖次数remainLotteryTimes----${remainLotteryTimes}次`)
//抽奖
if (remainLotteryTimes > 0) {
console.log('开始抽奖')
let lotteryResult = '';
for (let i = 0; i < new Array(remainLotteryTimes).fill('').length; i++) {
await lotteryForTurntableFarm()
console.log(`第${i + 1}次抽奖结果${JSON.stringify($.lotteryRes)}`);
if ($.lotteryRes.code === '0') {
turntableInfos.map((item) => {
if (item.type === $.lotteryRes.type) {
console.log(`lotteryRes.type${$.lotteryRes.type}`);
if ($.lotteryRes.type.match(/bean/g) && $.lotteryRes.type.match(/bean/g)[0] === 'bean') {
lotteryResult += `${item.name}个,`;
} else if ($.lotteryRes.type.match(/water/g) && $.lotteryRes.type.match(/water/g)[0] === 'water') {
lotteryResult += `${item.name},`;
} else {
lotteryResult += `${item.name},`;
}
}
})
//没有次数了
if ($.lotteryRes.remainLotteryTimes === 0) {
break
}
}
}
if (lotteryResult) {
console.log(`【天天抽奖】${lotteryResult.substr(0, lotteryResult.length - 1)}\n`)
// message += `【天天抽奖】${lotteryResult.substr(0, lotteryResult.length - 1)}\n`;
}
} else {
console.log('天天抽奖--抽奖机会为0次')
}
} else {
console.log('初始化天天抽奖得好礼失败')
}
}
//领取额外奖励水滴
async function getExtraAward() {
await farmAssistInit();
if ($.farmAssistResult.code === "0") {
if ($.farmAssistResult.assistFriendList && $.farmAssistResult.assistFriendList.length >= 2) {
if ($.farmAssistResult.status === 2) {
let num = 0;
for (let key of Object.keys($.farmAssistResult.assistStageList)) {
let vo = $.farmAssistResult.assistStageList[key]
if (vo.stageStaus === 2) {
await receiveStageEnergy()
if ($.receiveStageEnergy.code === "0") {
console.log(`已成功领取第${key + 1}阶段好友助力奖励:【${$.receiveStageEnergy.amount}】g水`)
num += $.receiveStageEnergy.amount
}
}
}
message += `【额外奖励】${num}g水领取成功\n`;
} else if ($.farmAssistResult.status === 3) {
console.log("已经领取过8好友助力额外奖励");
message += `【额外奖励】已被领取过\n`;
}
} else {
console.log("助力好友未达到2个");
message += `【额外奖励】领取失败,原因:给您助力的人未达2个\n`;
}
if ($.farmAssistResult.assistFriendList && $.farmAssistResult.assistFriendList.length > 0) {
let str = '';
$.farmAssistResult.assistFriendList.map((item, index) => {
if (index === ($.farmAssistResult.assistFriendList.length - 1)) {
str += item.nickName || "匿名用户";
} else {
str += (item.nickName || "匿名用户") + ',';
}
let date = new Date(item.time);
let time = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate() + ' ' + date.getHours() + ':' + date.getMinutes() + ':' + date.getMinutes();
console.log(`\n京东昵称【${item.nickName || "匿名用户"}】 在 ${time} 给您助过力\n`);
})
message += `【助力您的好友】${str}\n`;
}
console.log('领取额外奖励水滴结束\n');
} else {
await masterHelpTaskInitForFarm();
if ($.masterHelpResult.code === '0') {
if ($.masterHelpResult.masterHelpPeoples && $.masterHelpResult.masterHelpPeoples.length >= 5) {
// 已有五人助力。领取助力后的奖励
if (!$.masterHelpResult.masterGotFinal) {
await masterGotFinishedTaskForFarm();
if ($.masterGotFinished.code === '0') {
console.log(`已成功领取好友助力奖励:【${$.masterGotFinished.amount}】g水`);
message += `【额外奖励】${$.masterGotFinished.amount}g水领取成功\n`;
}
} else {
console.log("已经领取过5好友助力额外奖励");
message += `【额外奖励】已被领取过\n`;
}
} else {
console.log("助力好友未达到5个");
message += `【额外奖励】领取失败,原因:给您助力的人未达5个\n`;
}
if ($.masterHelpResult.masterHelpPeoples && $.masterHelpResult.masterHelpPeoples.length > 0) {
let str = '';
$.masterHelpResult.masterHelpPeoples.map((item, index) => {
if (index === ($.masterHelpResult.masterHelpPeoples.length - 1)) {
str += item.nickName || "匿名用户";
} else {
str += (item.nickName || "匿名用户") + ',';
}
let date = new Date(item.time);
let time = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate() + ' ' + date.getHours() + ':' + date.getMinutes() + ':' + date.getMinutes();
console.log(`\n京东昵称【${item.nickName || "匿名用户"}】 在 ${time} 给您助过力\n`);
})
message += `【助力您的好友】${str}\n`;
}
console.log('领取额外奖励水滴结束\n');
}
}
}
//助力好友
async function masterHelpShare() {
await initForFarm();
let salveHelpAddWater = 0;
let remainTimes = 3;//今日剩余助力次数,默认3次(京东农场每人每天3次助力机会)。
let helpSuccessPeoples = '';//成功助力好友
if(llhelp){
console.log('开始助力好友')
for (let code of newShareCodes) {
if(NoNeedCodes){
var llnoneed=false;
for (let NoNeedCode of NoNeedCodes) {
if (code==NoNeedCode){
llnoneed=true;
break;
}
}
if(llnoneed){
console.log(`${code}助力已满,跳过...`);
continue;
}
}
console.log(`${$.UserName}开始助力: ${code}`);
if (!code) continue;
if (!$.farmInfo.farmUserPro) {
console.log('未种植,跳过助力\n')
continue
}
if (code === $.farmInfo.farmUserPro.shareCode) {
console.log('不能为自己助力哦,跳过自己的shareCode\n')
continue
}
await masterHelp(code);
if ($.helpResult.code === '0') {
if ($.helpResult.helpResult.code === '0') {
//助力成功
salveHelpAddWater += $.helpResult.helpResult.salveHelpAddWater;
console.log(`【助力好友结果】: 已成功给【${$.helpResult.helpResult.masterUserInfo.nickName}】助力`);
console.log(`给好友【${$.helpResult.helpResult.masterUserInfo.nickName}】助力获得${$.helpResult.helpResult.salveHelpAddWater}g水滴`)
helpSuccessPeoples += ($.helpResult.helpResult.masterUserInfo.nickName || '匿名用户') + ',';
} else if ($.helpResult.helpResult.code === '8') {
console.log(`【助力好友结果】: 助力【${$.helpResult.helpResult.masterUserInfo.nickName}】失败,您今天助力次数已耗尽`);
} else if ($.helpResult.helpResult.code === '9') {
console.log(`【助力好友结果】: 之前给【${$.helpResult.helpResult.masterUserInfo.nickName}】助力过了`);
} else if ($.helpResult.helpResult.code === '10') {
NoNeedCodes.push(code);
console.log(`【助力好友结果】: 好友【${$.helpResult.helpResult.masterUserInfo.nickName}】已满五人助力`);
} else {
console.log(`助力其他情况:${JSON.stringify($.helpResult.helpResult)}`);
}
console.log(`【今日助力次数还剩】${$.helpResult.helpResult.remainTimes}次\n`);
remainTimes = $.helpResult.helpResult.remainTimes;
if ($.helpResult.helpResult.remainTimes === 0) {
console.log(`您当前助力次数已耗尽,跳出助力`);
break
}
} else {
console.log(`助力失败::${JSON.stringify($.helpResult)}`);
}
}
}
if ($.isLoon() || $.isQuanX() || $.isSurge()) {
let helpSuccessPeoplesKey = timeFormat() + $.farmInfo.farmUserPro.shareCode;
if (!$.getdata(helpSuccessPeoplesKey)) {
//把前一天的清除
$.setdata('', timeFormat(Date.now() - 24 * 60 * 60 * 1000) + $.farmInfo.farmUserPro.shareCode);
$.setdata('', helpSuccessPeoplesKey);
}
if (helpSuccessPeoples) {
if ($.getdata(helpSuccessPeoplesKey)) {
$.setdata($.getdata(helpSuccessPeoplesKey) + ',' + helpSuccessPeoples, helpSuccessPeoplesKey);
} else {
$.setdata(helpSuccessPeoples, helpSuccessPeoplesKey);
}
}
helpSuccessPeoples = $.getdata(helpSuccessPeoplesKey);
}
if (helpSuccessPeoples && helpSuccessPeoples.length > 0) {
message += `【您助力的好友👬】${helpSuccessPeoples.substr(0, helpSuccessPeoples.length - 1)}\n`;
}
if (salveHelpAddWater > 0) {
// message += `【助力好友👬】获得${salveHelpAddWater}g💧\n`;
console.log(`【助力好友👬】获得${salveHelpAddWater}g💧\n`);
}
message += `【今日剩余助力👬】${remainTimes}次\n`;
}
//水滴雨
async function executeWaterRains() {
let executeWaterRain = !$.farmTask.waterRainInit.f;
if (executeWaterRain) {
console.log(`水滴雨任务,每天两次,最多可得10g水滴`);
console.log(`两次水滴雨任务是否全部完成:${$.farmTask.waterRainInit.f ? '是' : '否'}`);
if ($.farmTask.waterRainInit.lastTime) {
if (Date.now() < ($.farmTask.waterRainInit.lastTime + 3 * 60 * 60 * 1000)) {
executeWaterRain = false;
// message += `【第${$.farmTask.waterRainInit.winTimes + 1}次水滴雨】未到时间,请${new Date($.farmTask.waterRainInit.lastTime + 3 * 60 * 60 * 1000).toLocaleTimeString()}再试\n`;
console.log(`【第${$.farmTask.waterRainInit.winTimes + 1}次水滴雨】未到时间,请${new Date($.farmTask.waterRainInit.lastTime + 3 * 60 * 60 * 1000).toLocaleTimeString()}再试\n`);
}
}
if (executeWaterRain) {
console.log(`开始水滴雨任务,这是第${$.farmTask.waterRainInit.winTimes + 1}次,剩余${2 - ($.farmTask.waterRainInit.winTimes + 1)}次`);
await waterRainForFarm();
console.log('水滴雨waterRain');
if ($.waterRain.code === '0') {
console.log('水滴雨任务执行成功,获得水滴:' + $.waterRain.addEnergy + 'g');
console.log(`【第${$.farmTask.waterRainInit.winTimes + 1}次水滴雨】获得${$.waterRain.addEnergy}g水滴\n`);
// message += `【第${$.farmTask.waterRainInit.winTimes + 1}次水滴雨】获得${$.waterRain.addEnergy}g水滴\n`;
}
}
} else {
// message += `【水滴雨】已全部完成,获得20g💧\n`;
}
}
//打卡领水活动
async function clockInIn() {
console.log('开始打卡领水活动(签到,关注,领券)');
await clockInInitForFarm();
if ($.clockInInit.code === '0') {
// 签到得水滴
if (!$.clockInInit.todaySigned) {
console.log('开始今日签到');
await clockInForFarm();
console.log(`打卡结果${JSON.stringify($.clockInForFarmRes)}`);
if ($.clockInForFarmRes.code === '0') {
// message += `【第${$.clockInForFarmRes.signDay}天签到】获得${$.clockInForFarmRes.amount}g💧\n`;
console.log(`【第${$.clockInForFarmRes.signDay}天签到】获得${$.clockInForFarmRes.amount}g💧\n`)
if ($.clockInForFarmRes.signDay === 7) {
//可以领取惊喜礼包
console.log('开始领取--惊喜礼包38g水滴');
await gotClockInGift();
if ($.gotClockInGiftRes.code === '0') {
// message += `【惊喜礼包】获得${$.gotClockInGiftRes.amount}g💧\n`;
console.log(`【惊喜礼包】获得${$.gotClockInGiftRes.amount}g💧\n`);
}
}
}
}
if ($.clockInInit.todaySigned && $.clockInInit.totalSigned === 7) {
console.log('开始领取--惊喜礼包38g水滴');
await gotClockInGift();
if ($.gotClockInGiftRes.code === '0') {
// message += `【惊喜礼包】获得${$.gotClockInGiftRes.amount}g💧\n`;
console.log(`【惊喜礼包】获得${$.gotClockInGiftRes.amount}g💧\n`);
}
}
// 限时关注得水滴
if ($.clockInInit.themes && $.clockInInit.themes.length > 0) {
for (let item of $.clockInInit.themes) {
if (!item.hadGot) {
console.log(`关注ID${item.id}`);
await clockInFollowForFarm(item.id, "theme", "1");
console.log(`themeStep1--结果${JSON.stringify($.themeStep1)}`);
if ($.themeStep1.code === '0') {
await clockInFollowForFarm(item.id, "theme", "2");
console.log(`themeStep2--结果${JSON.stringify($.themeStep2)}`);
if ($.themeStep2.code === '0') {
console.log(`关注${item.name},获得水滴${$.themeStep2.amount}g`);
}
}
}
}
}
// 限时领券得水滴
if ($.clockInInit.venderCoupons && $.clockInInit.venderCoupons.length > 0) {
for (let item of $.clockInInit.venderCoupons) {
if (!item.hadGot) {
console.log(`领券的ID${item.id}`);
await clockInFollowForFarm(item.id, "venderCoupon", "1");
console.log(`venderCouponStep1--结果${JSON.stringify($.venderCouponStep1)}`);
if ($.venderCouponStep1.code === '0') {
await clockInFollowForFarm(item.id, "venderCoupon", "2");
if ($.venderCouponStep2.code === '0') {
console.log(`venderCouponStep2--结果${JSON.stringify($.venderCouponStep2)}`);
console.log(`从${item.name}领券,获得水滴${$.venderCouponStep2.amount}g`);
}
}
}
}
}
}
console.log('开始打卡领水活动(签到,关注,领券)结束\n');
}
//
async function getAwardInviteFriend() {
await friendListInitForFarm();//查询好友列表
// console.log(`查询好友列表数据:${JSON.stringify($.friendList)}\n`)
if ($.friendList) {
console.log(`\n今日已邀请好友${$.friendList.inviteFriendCount}个 / 每日邀请上限${$.friendList.inviteFriendMax}个`);
console.log(`开始删除${$.friendList.friends && $.friendList.friends.length}个好友,可拿每天的邀请奖励`);
if ($.friendList.friends && $.friendList.friends.length > 0) {
for (let friend of $.friendList.friends) {
console.log(`\n开始删除好友 [${friend.shareCode}]`);
const deleteFriendForFarm = await request('deleteFriendForFarm', { "shareCode": `${friend.shareCode}`, "version": 8, "channel": 1 });
if (deleteFriendForFarm && deleteFriendForFarm.code === '0') {
console.log(`删除好友 [${friend.shareCode}] 成功\n`);
}
}
}
await receiveFriendInvite();//为他人助力,接受邀请成为别人的好友
if ($.friendList.inviteFriendCount > 0) {
if ($.friendList.inviteFriendCount > $.friendList.inviteFriendGotAwardCount) {
console.log('开始领取邀请好友的奖励');
await awardInviteFriendForFarm();
console.log(`领取邀请好友的奖励结果::${JSON.stringify($.awardInviteFriendRes)}`);
}
} else {
console.log('今日未邀请过好友')
}
} else {
console.log(`查询好友列表失败\n`);
}
}
//给好友浇水
async function doFriendsWater() {
await friendListInitForFarm();
console.log('开始给好友浇水...');
await taskInitForFarm();
const { waterFriendCountKey, waterFriendMax } = $.farmTask.waterFriendTaskInit;
console.log(`今日已给${waterFriendCountKey}个好友浇水`);
if (waterFriendCountKey < waterFriendMax) {
let needWaterFriends = [];
if ($.friendList.friends && $.friendList.friends.length > 0) {
$.friendList.friends.map((item, index) => {
if (item.friendState === 1) {