@@ -28,7 +28,7 @@ const $ = new Env('东东农场');
28
28
console . log ( '\n====================Hello World====================\n' ) ;
29
29
30
30
let cookiesArr = [ ] , cookie = '' , notify , newShareCodes , allMessage = '' ;
31
- let shareCodes = [ '' ]
31
+ let sharecodeSelf = [ ] , shareCodes = [ '' ]
32
32
let message = '' , subTitle = '' , option = { } , isFruitFinished = false ;
33
33
const retainWater = 100 ; //保留水滴大于多少g,默认100g;
34
34
let jdNotify = false ; //是否关闭通知,false打开通知推送,true关闭通知推送
@@ -38,12 +38,24 @@ const JD_API_HOST = 'https://api.m.jd.com/client.action';
38
38
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` ;
39
39
! ( async ( ) => {
40
40
await requireConfig ( ) ;
41
+ for ( let i = 0 ; i < cookiesArr . length ; i ++ ) {
42
+ cookie = cookiesArr [ i ] ;
43
+ $ . UserName = decodeURIComponent ( cookie . match ( / p t _ p i n = ( [ ^ ; ] + ) (? = ; ? ) / ) && cookie . match ( / p t _ p i n = ( [ ^ ; ] + ) (? = ; ? ) / ) [ 1 ] )
44
+ $ . index = i + 1 ;
45
+ console . log ( `\n开始【京东账号${ $ . index } 】${ $ . UserName } \n` ) ;
46
+ await initForFarm ( ) ;
47
+ if ( $ . farmInfo . farmUserPro ) {
48
+ console . log ( '助力码' , $ . farmInfo . farmUserPro . shareCode ) ;
49
+ sharecodeSelf . push ( $ . farmInfo . farmUserPro . shareCode ) ;
50
+ await $ . wait ( 1000 )
51
+ }
52
+ }
53
+ console . log ( '内部助力码' , sharecodeSelf . length , sharecodeSelf ) ;
41
54
for ( let i = 0 ; i < cookiesArr . length ; i ++ ) {
42
55
if ( cookiesArr [ i ] ) {
43
56
cookie = cookiesArr [ i ] ;
44
57
$ . UserName = decodeURIComponent ( cookie . match ( / p t _ p i n = ( [ ^ ; ] + ) (? = ; ? ) / ) && cookie . match ( / p t _ p i n = ( [ ^ ; ] + ) (? = ; ? ) / ) [ 1 ] )
45
58
$ . index = i + 1 ;
46
- $ . isLogin = true ;
47
59
console . log ( `\n开始【京东账号${ $ . index } 】${ $ . UserName } \n` ) ;
48
60
message = '' ;
49
61
subTitle = '' ;
@@ -493,7 +505,14 @@ async function turntableFarm() {
493
505
await initForTurntableFarm ( ) ;
494
506
if ( $ . initForTurntableFarmRes . code === '0' ) {
495
507
//领取定时奖励 //4小时一次
496
- let { timingIntervalHours, timingLastSysTime, sysTime, timingGotStatus, remainLotteryTimes, turntableInfos} = $ . initForTurntableFarmRes ;
508
+ let {
509
+ timingIntervalHours,
510
+ timingLastSysTime,
511
+ sysTime,
512
+ timingGotStatus,
513
+ remainLotteryTimes,
514
+ turntableInfos
515
+ } = $ . initForTurntableFarmRes ;
497
516
498
517
if ( ! timingGotStatus ) {
499
518
console . log ( `是否到了领取免费赠送的抽奖机会----${ sysTime > ( timingLastSysTime + 60 * 60 * timingIntervalHours * 1000 ) } ` )
@@ -837,7 +856,11 @@ async function getAwardInviteFriend() {
837
856
if ( $ . friendList . friends && $ . friendList . friends . length > 0 ) {
838
857
for ( let friend of $ . friendList . friends ) {
839
858
console . log ( `\n开始删除好友 [${ friend . shareCode } ]` ) ;
840
- const deleteFriendForFarm = await request ( 'deleteFriendForFarm' , { "shareCode" : `${ friend . shareCode } ` , "version" : 8 , "channel" : 1 } ) ;
859
+ const deleteFriendForFarm = await request ( 'deleteFriendForFarm' , {
860
+ "shareCode" : `${ friend . shareCode } ` ,
861
+ "version" : 8 ,
862
+ "channel" : 1
863
+ } ) ;
841
864
if ( deleteFriendForFarm && deleteFriendForFarm . code === '0' ) {
842
865
console . log ( `删除好友 [${ friend . shareCode } ] 成功\n` ) ;
843
866
}
@@ -919,7 +942,12 @@ async function doFriendsWater() {
919
942
//领取给3个好友浇水后的奖励水滴
920
943
async function getWaterFriendGotAward ( ) {
921
944
await taskInitForFarm ( ) ;
922
- const { waterFriendCountKey, waterFriendMax, waterFriendSendWater, waterFriendGotAward} = $ . farmTask . waterFriendTaskInit
945
+ const {
946
+ waterFriendCountKey,
947
+ waterFriendMax,
948
+ waterFriendSendWater,
949
+ waterFriendGotAward
950
+ } = $ . farmTask . waterFriendTaskInit
923
951
if ( waterFriendCountKey >= waterFriendMax ) {
924
952
if ( ! waterFriendGotAward ) {
925
953
await waterFriendGotAwardForFarm ( ) ;
@@ -1346,14 +1374,7 @@ function readShareCode() {
1346
1374
1347
1375
function shareCodesFormat ( ) {
1348
1376
return new Promise ( async resolve => {
1349
- newShareCodes = [ ] ;
1350
- if ( $ . shareCodesArr [ $ . index - 1 ] ) {
1351
- newShareCodes = $ . shareCodesArr [ $ . index - 1 ] . split ( '@' ) ;
1352
- } else {
1353
- console . log ( `由于您第${ $ . index } 个京东账号未提供shareCode,将采纳本脚本自带的助力码\n` )
1354
- const tempIndex = $ . index > shareCodes . length ? ( shareCodes . length - 1 ) : ( $ . index - 1 ) ;
1355
- newShareCodes = shareCodes [ tempIndex ] . split ( '@' ) ;
1356
- }
1377
+ newShareCodes = sharecodeSelf ;
1357
1378
const readShareCodeRes = await readShareCode ( ) ;
1358
1379
if ( readShareCodeRes && readShareCodeRes . code === 200 ) {
1359
1380
newShareCodes = [ ...new Set ( [ ...newShareCodes , ...( readShareCodeRes . data || [ ] ) ] ) ] ;
@@ -1369,7 +1390,6 @@ function requireConfig() {
1369
1390
notify = $ . isNode ( ) ? require ( './sendNotify' ) : '' ;
1370
1391
//Node.js用户请在jdCookie.js处填写京东ck;
1371
1392
const jdCookieNode = $ . isNode ( ) ? require ( './jdCookie.js' ) : '' ;
1372
- const jdFruitShareCodes = $ . isNode ( ) ? require ( './jdFruitShareCodes.js' ) : '' ;
1373
1393
//IOS等用户直接用NobyDa的jd cookie
1374
1394
if ( $ . isNode ( ) ) {
1375
1395
Object . keys ( jdCookieNode ) . forEach ( ( item ) => {
@@ -1384,17 +1404,11 @@ function requireConfig() {
1384
1404
}
1385
1405
console . log ( `共${ cookiesArr . length } 个京东账号\n` )
1386
1406
$ . shareCodesArr = [ ] ;
1387
- if ( $ . isNode ( ) ) {
1388
- Object . keys ( jdFruitShareCodes ) . forEach ( ( item ) => {
1389
- if ( jdFruitShareCodes [ item ] ) {
1390
- $ . shareCodesArr . push ( jdFruitShareCodes [ item ] )
1391
- }
1392
- } )
1393
- } else {
1407
+ if ( ! $ . isNode ( ) ) {
1394
1408
if ( $ . getdata ( 'jd_fruit_inviter' ) ) $ . shareCodesArr = $ . getdata ( 'jd_fruit_inviter' ) . split ( '\n' ) . filter ( item => ! ! item ) ;
1395
1409
console . log ( `\nBoxJs设置的${ $ . name } 好友邀请码:${ $ . getdata ( 'jd_fruit_inviter' ) ? $ . getdata ( 'jd_fruit_inviter' ) : '暂无' } \n` ) ;
1410
+ console . log ( `您提供了${ $ . shareCodesArr . length } 个账号的农场助力码\n` ) ;
1396
1411
}
1397
- console . log ( `您提供了${ $ . shareCodesArr . length } 个账号的农场助力码\n` ) ;
1398
1412
resolve ( )
1399
1413
} )
1400
1414
}
@@ -1560,7 +1574,11 @@ function Env(t, e) {
1560
1574
i = i ? i . replace ( / \n / g, "" ) . trim ( ) : i ;
1561
1575
let r = this . getdata ( "@chavy_boxjs_userCfgs.httpapi_timeout" ) ;
1562
1576
r = r ? 1 * r : 20 , r = e && e . timeout ? e . timeout : r ;
1563
- 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 : "*/*" } } ;
1577
+ const [ o , h ] = i . split ( "@" ) , n = {
1578
+ url : `http://${ h } /v1/scripting/evaluate` ,
1579
+ body : { script_text : t , mock_type : "cron" , timeout : r } ,
1580
+ headers : { "X-Key" : o , Accept : "*/*" }
1581
+ } ;
1564
1582
this . post ( n , ( t , e , i ) => s ( i ) )
1565
1583
} ) . catch ( t => this . logErr ( t ) )
1566
1584
}
@@ -1569,7 +1587,8 @@ function Env(t, e) {
1569
1587
if ( ! this . isNode ( ) ) return { } ;
1570
1588
{
1571
1589
this . fs = this . fs ? this . fs : require ( "fs" ) , this . path = this . path ? this . path : require ( "path" ) ;
1572
- 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 ) ;
1590
+ const t = this . path . resolve ( this . dataFile ) , e = this . path . resolve ( process . cwd ( ) , this . dataFile ) ,
1591
+ s = this . fs . existsSync ( t ) , i = ! s && this . fs . existsSync ( e ) ;
1573
1592
if ( ! s && ! i ) return { } ;
1574
1593
{
1575
1594
const i = s ? t : e ;
@@ -1585,7 +1604,8 @@ function Env(t, e) {
1585
1604
writedata ( ) {
1586
1605
if ( this . isNode ( ) ) {
1587
1606
this . fs = this . fs ? this . fs : require ( "fs" ) , this . path = this . path ? this . path : require ( "path" ) ;
1588
- 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 ) ;
1607
+ const t = this . path . resolve ( this . dataFile ) , e = this . path . resolve ( process . cwd ( ) , this . dataFile ) ,
1608
+ s = this . fs . existsSync ( t ) , i = ! s && this . fs . existsSync ( e ) , r = JSON . stringify ( this . data ) ;
1589
1609
s ? this . fs . writeFileSync ( t , r ) : i ? this . fs . writeFileSync ( e , r ) : this . fs . writeFileSync ( t , r )
1590
1610
}
1591
1611
}
@@ -1689,7 +1709,15 @@ function Env(t, e) {
1689
1709
1690
1710
time ( t , e = null ) {
1691
1711
const s = e ? new Date ( e ) : new Date ;
1692
- let i = { "M+" : s . getMonth ( ) + 1 , "d+" : s . getDate ( ) , "H+" : s . getHours ( ) , "m+" : s . getMinutes ( ) , "s+" : s . getSeconds ( ) , "q+" : Math . floor ( ( s . getMonth ( ) + 3 ) / 3 ) , S : s . getMilliseconds ( ) } ;
1712
+ let i = {
1713
+ "M+" : s . getMonth ( ) + 1 ,
1714
+ "d+" : s . getDate ( ) ,
1715
+ "H+" : s . getHours ( ) ,
1716
+ "m+" : s . getMinutes ( ) ,
1717
+ "s+" : s . getSeconds ( ) ,
1718
+ "q+" : Math . floor ( ( s . getMonth ( ) + 3 ) / 3 ) ,
1719
+ S : s . getMilliseconds ( )
1720
+ } ;
1693
1721
/ ( y + ) / . test ( t ) && ( t = t . replace ( RegExp . $1 , ( s . getFullYear ( ) + "" ) . substr ( 4 - RegExp . $1 . length ) ) ) ;
1694
1722
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 ) ) ) ;
1695
1723
return t
0 commit comments