Skip to content

Commit 0baec55

Browse files
Update
1 parent 4a53f38 commit 0baec55

11 files changed

+401
-347
lines changed

jdFruitShareCodes.js

-35
This file was deleted.

jd_fruit.js

+54-26
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const $ = new Env('东东农场');
2828
console.log('\n====================Hello World====================\n');
2929

3030
let cookiesArr = [], cookie = '', notify, newShareCodes, allMessage = '';
31-
let shareCodes = ['']
31+
let sharecodeSelf = [], shareCodes = ['']
3232
let message = '', subTitle = '', option = {}, isFruitFinished = false;
3333
const retainWater = 100;//保留水滴大于多少g,默认100g;
3434
let jdNotify = false;//是否关闭通知,false打开通知推送,true关闭通知推送
@@ -38,12 +38,24 @@ const JD_API_HOST = 'https://api.m.jd.com/client.action';
3838
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`;
3939
!(async () => {
4040
await requireConfig();
41+
for (let i = 0; i < cookiesArr.length; i++) {
42+
cookie = cookiesArr[i];
43+
$.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[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);
4154
for (let i = 0; i < cookiesArr.length; i++) {
4255
if (cookiesArr[i]) {
4356
cookie = cookiesArr[i];
4457
$.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1])
4558
$.index = i + 1;
46-
$.isLogin = true;
4759
console.log(`\n开始【京东账号${$.index}${$.UserName}\n`);
4860
message = '';
4961
subTitle = '';
@@ -493,7 +505,14 @@ async function turntableFarm() {
493505
await initForTurntableFarm();
494506
if ($.initForTurntableFarmRes.code === '0') {
495507
//领取定时奖励 //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;
497516

498517
if (!timingGotStatus) {
499518
console.log(`是否到了领取免费赠送的抽奖机会----${sysTime > (timingLastSysTime + 60 * 60 * timingIntervalHours * 1000)}`)
@@ -837,7 +856,11 @@ async function getAwardInviteFriend() {
837856
if ($.friendList.friends && $.friendList.friends.length > 0) {
838857
for (let friend of $.friendList.friends) {
839858
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+
});
841864
if (deleteFriendForFarm && deleteFriendForFarm.code === '0') {
842865
console.log(`删除好友 [${friend.shareCode}] 成功\n`);
843866
}
@@ -919,7 +942,12 @@ async function doFriendsWater() {
919942
//领取给3个好友浇水后的奖励水滴
920943
async function getWaterFriendGotAward() {
921944
await taskInitForFarm();
922-
const {waterFriendCountKey, waterFriendMax, waterFriendSendWater, waterFriendGotAward} = $.farmTask.waterFriendTaskInit
945+
const {
946+
waterFriendCountKey,
947+
waterFriendMax,
948+
waterFriendSendWater,
949+
waterFriendGotAward
950+
} = $.farmTask.waterFriendTaskInit
923951
if (waterFriendCountKey >= waterFriendMax) {
924952
if (!waterFriendGotAward) {
925953
await waterFriendGotAwardForFarm();
@@ -1346,14 +1374,7 @@ function readShareCode() {
13461374

13471375
function shareCodesFormat() {
13481376
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;
13571378
const readShareCodeRes = await readShareCode();
13581379
if (readShareCodeRes && readShareCodeRes.code === 200) {
13591380
newShareCodes = [...new Set([...newShareCodes, ...(readShareCodeRes.data || [])])];
@@ -1369,7 +1390,6 @@ function requireConfig() {
13691390
notify = $.isNode() ? require('./sendNotify') : '';
13701391
//Node.js用户请在jdCookie.js处填写京东ck;
13711392
const jdCookieNode = $.isNode() ? require('./jdCookie.js') : '';
1372-
const jdFruitShareCodes = $.isNode() ? require('./jdFruitShareCodes.js') : '';
13731393
//IOS等用户直接用NobyDa的jd cookie
13741394
if ($.isNode()) {
13751395
Object.keys(jdCookieNode).forEach((item) => {
@@ -1384,17 +1404,11 @@ function requireConfig() {
13841404
}
13851405
console.log(`共${cookiesArr.length}个京东账号\n`)
13861406
$.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()) {
13941408
if ($.getdata('jd_fruit_inviter')) $.shareCodesArr = $.getdata('jd_fruit_inviter').split('\n').filter(item => !!item);
13951409
console.log(`\nBoxJs设置的${$.name}好友邀请码:${$.getdata('jd_fruit_inviter') ? $.getdata('jd_fruit_inviter') : '暂无'}\n`);
1410+
console.log(`您提供了${$.shareCodesArr.length}个账号的农场助力码\n`);
13961411
}
1397-
console.log(`您提供了${$.shareCodesArr.length}个账号的农场助力码\n`);
13981412
resolve()
13991413
})
14001414
}
@@ -1560,7 +1574,11 @@ function Env(t, e) {
15601574
i = i ? i.replace(/\n/g, "").trim() : i;
15611575
let r = this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");
15621576
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+
};
15641582
this.post(n, (t, e, i) => s(i))
15651583
}).catch(t => this.logErr(t))
15661584
}
@@ -1569,7 +1587,8 @@ function Env(t, e) {
15691587
if (!this.isNode()) return {};
15701588
{
15711589
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);
15731592
if (!s && !i) return {};
15741593
{
15751594
const i = s ? t : e;
@@ -1585,7 +1604,8 @@ function Env(t, e) {
15851604
writedata() {
15861605
if (this.isNode()) {
15871606
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);
15891609
s ? this.fs.writeFileSync(t, r) : i ? this.fs.writeFileSync(e, r) : this.fs.writeFileSync(t, r)
15901610
}
15911611
}
@@ -1689,7 +1709,15 @@ function Env(t, e) {
16891709

16901710
time(t, e = null) {
16911711
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+
};
16931721
/(y+)/.test(t) && (t = t.replace(RegExp.$1, (s.getFullYear() + "").substr(4 - RegExp.$1.length)));
16941722
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)));
16951723
return t

jd_health.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ var cookie = '', res = '', UserName;
131131
e_1 = _g.sent();
132132
console.log('Error', e_1);
133133
return [3 /*break*/, 24];
134-
case 21: return [4 /*yield*/, (0, TS_USER_AGENTS_1.wait)(10000)];
134+
case 21: return [4 /*yield*/, (0, TS_USER_AGENTS_1.wait)(3000)];
135135
case 22:
136136
_g.sent();
137137
_g.label = 23;

jd_health.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ let cookie: string = '', res: any = '', UserName: string
5959
console.log('Error', e)
6060
break
6161
}
62-
await wait(10000)
62+
await wait(3000)
6363
}
6464
}
6565
})();

jd_nzmh.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,13 @@ function doTask(taskId) {
164164
console.log(`${$.name} API请求失败,请检查网路重试`)
165165
} else {
166166
data = JSON.parse(data.match(/query\((.*)\n/)[1])
167-
if (data.data.complete_task_list.includes(taskId)) {
168-
console.log(`任务完成成功,当前幸运值${data.data.curbless}`)
169-
$.userInfo.bless = data.data.curbless
167+
if (data.errcode === 8004) {
168+
console.log(`任务完成失败,无效任务ID`)
169+
} else {
170+
if (data.data.complete_task_list.includes(taskId)) {
171+
console.log(`任务完成成功,当前幸运值${data.data.curbless}`)
172+
$.userInfo.bless = data.data.curbless
173+
}
170174
}
171175
}
172176
} catch (e) {

0 commit comments

Comments
 (0)