yyds
parent
bb8752504a
commit
aeebc4e59a
200
jd_fruit.js
200
jd_fruit.js
|
@ -1,55 +1,74 @@
|
|||
/*
|
||||
东东水果:脚本更新地址 jd_fruit.js
|
||||
更新时间:2021-11-7
|
||||
东东水果:脚本更新地址 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 * * * jd_fruit.js, tag=东东农场, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jdnc.png, enabled=true
|
||||
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=jd_fruit.js,tag=东东农场
|
||||
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=jd_fruit.js
|
||||
东东农场 = 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=jd_fruit.js, cronexpr="5 6-18/6 * * *", timeout=3600, enable=true
|
||||
东东农场 = 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
|
||||
|
||||
export DO_TEN_WATER_AGAIN="" 默认再次浇水
|
||||
|
||||
*/
|
||||
const $ = new Env('东东农场');
|
||||
let cookiesArr = [], cookie = '', jdFruitShareArr = [], isBox = false, notify, newShareCodes, allMessage = '';
|
||||
const $ = new Env('东东农场_内部互助');
|
||||
let cookiesArr = [], cookie = '', isBox = false, notify,allMessage = '';
|
||||
//助力好友分享码(最多3个,否则后面的助力失败),原因:京东农场每人每天只有3次助力机会
|
||||
//此此内容是IOS用户下载脚本到本地使用,填写互助码的地方,同一京东账号的好友互助码请使用@符号隔开。
|
||||
//下面给出两个账号的填写示例(iOS只支持2个京东账号)
|
||||
let shareCodes = [ // 这个列表填入你要助力的好友的shareCode
|
||||
//账号一的好友shareCode,不同好友的shareCode中间用@符号隔开
|
||||
'',
|
||||
//账号二的好友shareCode,不同好友的shareCode中间用@符号隔开
|
||||
'',
|
||||
]
|
||||
|
||||
let newShareCodes=[];
|
||||
let message = '', subTitle = '', option = {}, isFruitFinished = false;
|
||||
const retainWater = 100;//保留水滴大于多少g,默认100g;
|
||||
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表示不换豆(继续浇水),脚本默认是浇水
|
||||
let randomCount = $.isNode() ? 20 : 5;
|
||||
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`;
|
||||
|
||||
!(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;
|
||||
}
|
||||
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;
|
||||
await GetCollect();
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < cookiesArr.length; i++) {
|
||||
if (cookiesArr[i]) {
|
||||
cookie = cookiesArr[i];
|
||||
|
@ -70,7 +89,7 @@ const urlSchema = `openjd://virtual?params=%7B%20%22category%22:%20%22jump%22,%2
|
|||
message = '';
|
||||
subTitle = '';
|
||||
option = {};
|
||||
await shareCodesFormat();
|
||||
$.retry = 0;
|
||||
await jdFruit();
|
||||
}
|
||||
}
|
||||
|
@ -89,9 +108,7 @@ async function jdFruit() {
|
|||
try {
|
||||
await initForFarm();
|
||||
if ($.farmInfo.farmUserPro) {
|
||||
// option['media-url'] = $.farmInfo.farmUserPro.goodsImage;
|
||||
message = `【水果名称】${$.farmInfo.farmUserPro.name}\n`;
|
||||
console.log(`\n【京东账号${$.index}(${$.UserName})的${$.name}好友互助码】${$.farmInfo.farmUserPro.shareCode}\n`);
|
||||
console.log(`\n【已成功兑换水果】${$.farmInfo.farmUserPro.winTimes}次\n`);
|
||||
message += `【已兑换水果】${$.farmInfo.farmUserPro.winTimes}次\n`;
|
||||
await masterHelpShare();//助力好友
|
||||
|
@ -119,16 +136,11 @@ async function jdFruit() {
|
|||
await getTenWaterAward();//领取10浇水奖励
|
||||
await getWaterFriendGotAward();//领取为2好友浇水奖励
|
||||
await duck();
|
||||
if(!process.env.DO_TEN_WATER_AGAIN){
|
||||
console.log('执行再次浇水')
|
||||
await doTenWaterAgain();//再次浇水
|
||||
} else {
|
||||
console.log('不执行再次浇水,攒水滴')
|
||||
}
|
||||
await predictionFruit();//预测水果成熟时间
|
||||
} else {
|
||||
console.log(`初始化农场数据异常, 请登录京东 app查看农场0元水果功能是否正常,农场初始化数据: ${JSON.stringify($.farmInfo)}`);
|
||||
message = `【数据异常】请手动登录京东app查看此账号${$.name}是否正常`;
|
||||
console.log(`初始化农场数据异常, 请登录京东 app查看农场功能是否正常`);
|
||||
message+=`初始化农场数据异常, 请登录京东 app查看农场功能是否正常`;
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(`任务执行异常,请检查执行日志 ‼️‼️`);
|
||||
|
@ -164,7 +176,9 @@ async function doDailyTask() {
|
|||
}
|
||||
}
|
||||
console.log(`签到结束,开始广告浏览任务`);
|
||||
if (!$.farmTask.gotBrowseTaskAdInit.f) {
|
||||
if ($.farmTask.gotBrowseTaskAdInit.f) {
|
||||
console.log(`今天已经做过浏览广告任务\n`);
|
||||
} else {
|
||||
let adverts = $.farmTask.gotBrowseTaskAdInit.userBrowseTaskAds
|
||||
let browseReward = 0
|
||||
let browseSuccess = 0
|
||||
|
@ -201,8 +215,6 @@ async function doDailyTask() {
|
|||
console.log(`【广告浏览】完成${browseSuccess}个,获得${browseReward}g💧\n`);
|
||||
// message += `【广告浏览】完成${browseSuccess}个,获得${browseReward}g💧\n`;
|
||||
}
|
||||
} else {
|
||||
console.log(`今天已经做过浏览广告任务\n`);
|
||||
}
|
||||
//定时领水
|
||||
if (!$.farmTask.gotThreeMealInit.f) {
|
||||
|
@ -226,13 +238,7 @@ async function doDailyTask() {
|
|||
} else {
|
||||
console.log(`给${$.farmTask.waterFriendTaskInit.waterFriendMax}个好友浇水任务已完成\n`)
|
||||
}
|
||||
// await Promise.all([
|
||||
// clockInIn(),//打卡领水
|
||||
// executeWaterRains(),//水滴雨
|
||||
// masterHelpShare(),//助力好友
|
||||
// getExtraAward(),//领取额外水滴奖励
|
||||
// turntableFarm()//天天抽奖得好礼
|
||||
// ])
|
||||
|
||||
await getAwardInviteFriend();
|
||||
await clockInIn();//打卡领水
|
||||
await executeWaterRains();//水滴雨
|
||||
|
@ -668,14 +674,18 @@ async function getExtraAward() {
|
|||
//助力好友
|
||||
async function masterHelpShare() {
|
||||
console.log('开始助力好友')
|
||||
await initForFarm();
|
||||
let salveHelpAddWater = 0;
|
||||
let remainTimes = 3;//今日剩余助力次数,默认3次(京东农场每人每天3次助力机会)。
|
||||
let helpSuccessPeoples = '';//成功助力好友
|
||||
console.log(`格式化后的助力码::${JSON.stringify(newShareCodes)}\n`);
|
||||
|
||||
for (let code of newShareCodes) {
|
||||
console.log(`开始助力京东账号${$.index} - ${$.nickName || $.UserName}的好友: ${code}`);
|
||||
console.log(`${$.UserName}开始助力: ${code}`);
|
||||
if (!code) continue;
|
||||
if (!$.farmInfo.farmUserPro) {
|
||||
console.log('未种植,跳过助力\n')
|
||||
continue
|
||||
}
|
||||
if (code === $.farmInfo.farmUserPro.shareCode) {
|
||||
console.log('不能为自己助力哦,跳过自己的shareCode\n')
|
||||
continue
|
||||
|
@ -985,6 +995,20 @@ async function duck() {
|
|||
}
|
||||
}
|
||||
}
|
||||
async function GetCollect() {
|
||||
try {
|
||||
await initForFarm();
|
||||
if ($.farmInfo.farmUserPro) {
|
||||
console.log(`\n【京东账号${$.index}(${$.UserName})的${$.name}好友互助码】${$.farmInfo.farmUserPro.shareCode}`);
|
||||
newShareCodes.push($.farmInfo.farmUserPro.shareCode)
|
||||
} else {
|
||||
console.log(`\n【京东账号${$.index}(${$.UserName})的${$.name}好友互助码】\n数据异常,使用ccwav的互助码:f910ae66879a422daeb32f9250fc5e2e`);
|
||||
newShareCodes.push("f910ae66879a422daeb32f9250fc5e2e");
|
||||
}
|
||||
} catch (e) {
|
||||
$.logErr(e);
|
||||
}
|
||||
}
|
||||
// ========================API调用接口========================
|
||||
//鸭子,点我有惊喜
|
||||
async function getFullCollectionReward() {
|
||||
|
@ -1292,7 +1316,7 @@ async function showMsg() {
|
|||
$.msg($.name, subTitle, message, option);
|
||||
if ($.isNode()) {
|
||||
allMessage += `${subTitle}\n${message}${$.index !== cookiesArr.length ? '\n\n' : ''}`;
|
||||
// await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName || $.UserName}`, `${subTitle}\n${message}`);
|
||||
// await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName}`, `${subTitle}\n${message}`);
|
||||
}
|
||||
} else {
|
||||
$.log(`\n${message}\n`);
|
||||
|
@ -1308,56 +1332,13 @@ function timeFormat(time) {
|
|||
}
|
||||
return date.getFullYear() + '-' + ((date.getMonth() + 1) >= 10 ? (date.getMonth() + 1) : '0' + (date.getMonth() + 1)) + '-' + (date.getDate() >= 10 ? date.getDate() : '0' + date.getDate());
|
||||
}
|
||||
function readShareCode() {
|
||||
return new Promise(async resolve => {
|
||||
$.get({url: `http://transfer.nz.lu/farm`, timeout: 10000}, (err, resp, data) => {
|
||||
try {
|
||||
if (err) {
|
||||
console.log(JSON.stringify(err))
|
||||
console.log(`${$.name} API请求失败,请检查网路重试`)
|
||||
} else {
|
||||
if (data) {
|
||||
console.log(`随机取个${randomCount}码放到您固定的互助码后面(不影响已有固定互助)`)
|
||||
data = JSON.parse(data);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
$.logErr(e, resp)
|
||||
} finally {
|
||||
resolve(data);
|
||||
}
|
||||
})
|
||||
await $.wait(10000);
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
function shareCodesFormat() {
|
||||
return new Promise(async resolve => {
|
||||
// console.log(`第${$.index}个京东账号的助力码:::${$.shareCodesArr[$.index - 1]}`)
|
||||
newShareCodes = [];
|
||||
if ($.shareCodesArr[$.index - 1]) {
|
||||
newShareCodes = $.shareCodesArr[$.index - 1].split('@');
|
||||
} else {
|
||||
console.log(`由于您第${$.index}个京东账号未提供shareCode,将采纳本脚本自带的助力码\n`)
|
||||
const tempIndex = $.index > shareCodes.length ? (shareCodes.length - 1) : ($.index - 1);
|
||||
newShareCodes = shareCodes[tempIndex].split('@');
|
||||
}
|
||||
// const readShareCodeRes = await readShareCode();
|
||||
// if (readShareCodeRes && readShareCodeRes.code === 200) {
|
||||
// // newShareCodes = newShareCodes.concat(readShareCodeRes.data || []);
|
||||
// newShareCodes = [...new Set([...newShareCodes, ...(readShareCodeRes.data || [])])];
|
||||
// }
|
||||
console.log(`第${$.index}个京东账号将要助力的好友${JSON.stringify(newShareCodes)}`)
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
|
||||
function requireConfig() {
|
||||
return new Promise(resolve => {
|
||||
console.log('开始获取配置文件\n')
|
||||
notify = $.isNode() ? require('./sendNotify') : '';
|
||||
//Node.js用户请在jdCookie.js处填写京东ck;
|
||||
const jdCookieNode = $.isNode() ? require('./jdCookie.js') : '';
|
||||
const jdFruitShareCodes = $.isNode() ? require('./jdFruitShareCodes.js') : '';
|
||||
//IOS等用户直接用NobyDa的jd cookie
|
||||
if ($.isNode()) {
|
||||
Object.keys(jdCookieNode).forEach((item) => {
|
||||
|
@ -1371,54 +1352,40 @@ function requireConfig() {
|
|||
}
|
||||
console.log(`共${cookiesArr.length}个京东账号\n`)
|
||||
$.shareCodesArr = [];
|
||||
if ($.isNode()) {
|
||||
Object.keys(jdFruitShareCodes).forEach((item) => {
|
||||
if (jdFruitShareCodes[item]) {
|
||||
$.shareCodesArr.push(jdFruitShareCodes[item])
|
||||
}
|
||||
})
|
||||
} else {
|
||||
if ($.getdata('jd_fruit_inviter')) $.shareCodesArr = $.getdata('jd_fruit_inviter').split('\n').filter(item => !!item);
|
||||
console.log(`\nBoxJs设置的${$.name}好友邀请码:${$.getdata('jd_fruit_inviter') ? $.getdata('jd_fruit_inviter') : '暂无'}\n`);
|
||||
}
|
||||
// console.log(`$.shareCodesArr::${JSON.stringify($.shareCodesArr)}`)
|
||||
// console.log(`jdFruitShareArr账号长度::${$.shareCodesArr.length}`)
|
||||
console.log(`您提供了${$.shareCodesArr.length}个账号的农场助力码\n`);
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
function TotalBean() {
|
||||
return new Promise(async resolve => {
|
||||
const options = {
|
||||
"url": `https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2`,
|
||||
"headers": {
|
||||
"Accept": "application/json,text/plain, */*",
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
"Accept-Encoding": "gzip, deflate, br",
|
||||
url: "https://me-api.jd.com/user_new/info/GetJDUserInfoUnion",
|
||||
headers: {
|
||||
Host: "me-api.jd.com",
|
||||
Accept: "*/*",
|
||||
Connection: "keep-alive",
|
||||
Cookie: cookie,
|
||||
"User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "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"),
|
||||
"Accept-Language": "zh-cn",
|
||||
"Connection": "keep-alive",
|
||||
"Cookie": cookie,
|
||||
"Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2",
|
||||
"User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "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")
|
||||
"Referer": "https://home.m.jd.com/myJd/newhome.action?sceneval=2&ufc=&",
|
||||
"Accept-Encoding": "gzip, deflate, br"
|
||||
}
|
||||
}
|
||||
$.post(options, (err, resp, data) => {
|
||||
$.get(options, (err, resp, data) => {
|
||||
try {
|
||||
if (err) {
|
||||
console.log(`${JSON.stringify(err)}`)
|
||||
console.log(`${$.name} API请求失败,请检查网路重试`)
|
||||
$.logErr(err)
|
||||
} else {
|
||||
if (data) {
|
||||
data = JSON.parse(data);
|
||||
if (data['retcode'] === 13) {
|
||||
if (data['retcode'] === "1001") {
|
||||
$.isLogin = false; //cookie过期
|
||||
return
|
||||
return;
|
||||
}
|
||||
if (data['retcode'] === 0 && data.base && data.base.nickname) {
|
||||
$.nickName = data.base.nickname;
|
||||
if (data['retcode'] === "0" && data.data && data.data.hasOwnProperty("userInfo")) {
|
||||
$.nickName = data.data.userInfo.baseInfo.nickname;
|
||||
}
|
||||
} else {
|
||||
console.log(`京东服务器返回空数据`)
|
||||
$.log('京东服务器返回空数据');
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
|
@ -1464,7 +1431,6 @@ function safeGet(data) {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function taskUrl(function_id, body = {}) {
|
||||
return {
|
||||
url: `${JD_API_HOST}?functionId=${function_id}&body=${encodeURIComponent(JSON.stringify(body))}&appid=wh5`,
|
||||
|
|
Loading…
Reference in New Issue