mirror of
https://github.com/shufflewzc/faker2.git
synced 2025-04-23 02:48:44 +08:00
Update jd_fruit_task.js
This commit is contained in:
parent
fef6312e44
commit
bfe5e356df
656
jd_fruit_task.js
656
jd_fruit_task.js
@ -1,46 +1,56 @@
|
||||
/*
|
||||
东东水果:脚本更新地址 jd_fruit.js
|
||||
更新时间:2022-11-8
|
||||
活动入口:京东APP我的--东东农场
|
||||
东东水果:脚本更新地址 jd_fruit_task.js
|
||||
更新时间:2023-7-17
|
||||
修复当日浇水次数统计与预估成熟时间
|
||||
活动入口:京东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免费水果
|
||||
15 6-18/6 * * * jd_fruit.js, tag=东东农场, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jdnc.png, enabled=true
|
||||
5 6-18/6 * * * jd_fruit_task.js, tag=东东农场日常任务, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jdnc.png, enabled=true
|
||||
=========================Loon=============================
|
||||
[Script]
|
||||
cron "15 6-18/6 * * *" script-path=jd_fruit.js,tag=东东农场
|
||||
cron "5 6-18/6 * * *" script-path=jd_fruit_task.js,tag=东东农场日常任务
|
||||
|
||||
=========================Surge============================
|
||||
东东农场 = type=cron,cronexp="15 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=jd_fruit_task.js
|
||||
|
||||
=========================小火箭===========================
|
||||
东东农场 = type=cron,script-path=jd_fruit.js, cronexpr="15 6-18/6 * * *", timeout=3600, enable=true
|
||||
jd免费水果 搬的https://github.com/liuxiaoyucc/jd-helper/blob/a6f275d9785748014fc6cca821e58427162e9336/fruit/fruit.js
|
||||
变量:
|
||||
export DO_TEN_WATER_AGAIN='true' 攒水滴只交10次水,默认不攒水滴
|
||||
export FRUIT_FAST_CARD='true' 使用快速浇水卡,水多可开启
|
||||
东东农场日常任务 = type=cron,script-path=jd_fruit_task.js, cronexpr="5 6-18/6 * * *", timeout=3600, enable=true
|
||||
|
||||
export DO_TEN_WATER_AGAIN="" 默认再次浇水
|
||||
|
||||
*/
|
||||
const $ = new Env('东东农场-任务');
|
||||
let cookiesArr = [], cookie = '', jdFruitShareArr = [], isBox = false, notify, newShareCodes, allMessage = '';
|
||||
const $ = new Env('东东农场日常任务');
|
||||
let cookiesArr = [],
|
||||
cookie = '',
|
||||
jdFruitShareArr = [],
|
||||
isBox = false,
|
||||
notify, newShareCodes, allMessage = '';
|
||||
//助力好友分享码(最多3个,否则后面的助力失败),原因:京东农场每人每天只有3次助力机会
|
||||
//此此内容是IOS用户下载脚本到本地使用,填写互助码的地方,同一京东账号的好友互助码请使用@符号隔开。
|
||||
//下面给出两个账号的填写示例(iOS只支持2个京东账号)
|
||||
let shareCodes = [ // 这个列表填入你要助力的好友的shareCode
|
||||
''
|
||||
// //账号一的好友shareCode,不同好友的shareCode中间用@符号隔开
|
||||
// '5853550f71014282912b76d95beb84c0@b58ddba3317b44ceb0ac86ea8952998c@8d724eb95e3847b6a1526587d1836f27@a80b7d1db41a4381b742232da9d22443@ce107b8f64d24f62a92292180f764018@c73ea563a77d4464b273503d3838fec1@0dd9a7fd1feb449fb1bf854a3ec0e801',
|
||||
// //账号二的好友shareCode,不同好友的shareCode中间用@符号隔开
|
||||
// '5853550f71014282912b76d95beb84c0@b58ddba3317b44ceb0ac86ea8952998c@8d724eb95e3847b6a1526587d1836f27@a80b7d1db41a4381b742232da9d22443@ce107b8f64d24f62a92292180f764018@c73ea563a77d4464b273503d3838fec1@0dd9a7fd1feb449fb1bf854a3ec0e801',
|
||||
]
|
||||
|
||||
let message = '', subTitle = '', option = {}, isFruitFinished = false;
|
||||
const retainWater = 100;//保留水滴大于多少g,默认100g;
|
||||
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 codeType = 0;
|
||||
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`;
|
||||
const JD_ZLC_URL = process.env.JD_ZLC_URL ? process.env.JD_ZLC_URL : "https://zlc1.chaoyi996.com";
|
||||
|
||||
|
||||
let lnrun = 0;
|
||||
!(async() => {
|
||||
await requireConfig();
|
||||
if (!cookiesArr[0]) {
|
||||
@ -54,8 +64,8 @@ const JD_ZLC_URL = process.env.JD_ZLC_URL ? process.env.JD_ZLC_URL : "https://zl
|
||||
$.index = i + 1;
|
||||
$.isLogin = true;
|
||||
$.nickName = '';
|
||||
await TotalBean();
|
||||
console.log(`开始【京东账号${$.index}】${$.nickName || $.UserName}\n`);
|
||||
//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" });
|
||||
|
||||
@ -68,8 +78,15 @@ const JD_ZLC_URL = process.env.JD_ZLC_URL ? process.env.JD_ZLC_URL : "https://zl
|
||||
subTitle = '';
|
||||
option = {};
|
||||
$.UA = require('./USER_AGENTS').UARAM();
|
||||
await shareCodesFormat();
|
||||
$.retry = 0;
|
||||
lnrun++;
|
||||
await jdFruit();
|
||||
if (lnrun == 3) {
|
||||
console.log(`\n【访问接口次数达到3次,休息一分钟.....】\n`);
|
||||
await $.wait(60 * 1000);
|
||||
lnrun = 0;
|
||||
}
|
||||
await $.wait(30 * 1000);
|
||||
}
|
||||
}
|
||||
if ($.isNode() && allMessage && $.ctrTemp) {
|
||||
@ -83,13 +100,13 @@ const JD_ZLC_URL = process.env.JD_ZLC_URL ? process.env.JD_ZLC_URL : "https://zl
|
||||
$.done();
|
||||
})
|
||||
async function jdFruit() {
|
||||
subTitle = `【京东账号${$.index}🆔】${$.nickName || $.UserName}`;
|
||||
subTitle = `【京东账号${$.index}】${$.nickName || $.UserName}`;
|
||||
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【京东账号${$.index}(${$.UserName})的${$.name}好友互助码】${$.farmInfo.farmUserPro.shareCode}\n`);
|
||||
console.log(`\n【已成功兑换水果】${$.farmInfo.farmUserPro.winTimes}次\n`);
|
||||
message += `【已兑换水果】${$.farmInfo.farmUserPro.winTimes}次\n`;
|
||||
//await masterHelpShare(); //助力好友
|
||||
@ -125,13 +142,18 @@ async function jdFruit() {
|
||||
}
|
||||
await predictionFruit(); //预测水果成熟时间
|
||||
} else {
|
||||
console.log(`初始化农场数据异常, 请登录京东 app查看农场0元水果功能是否正常,农场初始化数据: ${JSON.stringify($.farmInfo)}`);
|
||||
message = `【数据异常】请手动登录京东app查看此账号${$.name}是否正常`;
|
||||
console.log(`初始化农场数据异常, 请登录京东 app查看农场0元水果功能是否正常。`);
|
||||
if ($.retry < 2) {
|
||||
$.retry++
|
||||
console.log(`等待3秒后重试,第:${$.retry}次`);
|
||||
await $.wait(3000);
|
||||
await jdFruit();
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(`任务执行异常,请检查执行日志 ‼️‼️`);
|
||||
$.logErr(e);
|
||||
const errMsg = `京东账号${$.index} ${$.nickName || $.UserName}\n任务执行异常,请检查执行日志 ‼️‼️`;
|
||||
// const errMsg = `京东账号${$.index} ${$.nickName || $.UserName}\n任务执行异常,请检查执行日志 ‼️‼️`;
|
||||
// if ($.isNode()) await notify.sendNotify(`${$.name}`, errMsg);
|
||||
// $.msg($.name, '', `${errMsg}`)
|
||||
}
|
||||
@ -139,19 +161,19 @@ async function jdFruit() {
|
||||
}
|
||||
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(`开始签到`);
|
||||
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) {
|
||||
@ -227,24 +249,52 @@ async function doDailyTask() {
|
||||
// await Promise.all([
|
||||
// clockInIn(),//打卡领水
|
||||
// executeWaterRains(),//水滴雨
|
||||
masterHelpShare(),//助力好友
|
||||
// masterHelpShare(),//助力好友
|
||||
// getExtraAward(),//领取额外水滴奖励
|
||||
// turntableFarm()//天天抽奖得好礼
|
||||
// ])
|
||||
//await getAwardInviteFriend();
|
||||
await getTreasureBoxAwardTask(); //去首页逛逛“领京豆”
|
||||
await clockInIn(); //打卡领水
|
||||
await executeWaterRains(); //水滴雨
|
||||
await getExtraAward(); //领取额外水滴奖励
|
||||
await turntableFarm() //天天抽奖得好礼
|
||||
}
|
||||
async function getTreasureBoxAwardTask() {
|
||||
await taskInitForFarm();
|
||||
const treasureBox = $.farmTask['treasureBoxInit-getBean'];
|
||||
if (!treasureBox) {
|
||||
console.log(`此帐号不支持去首页逛逛“领京豆”任务`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!treasureBox.f) {
|
||||
console.log(`正在进行任务:${treasureBox.taskMainTitle}`);
|
||||
await ddnc_getTreasureBoxAward(1);
|
||||
if ($.treasureResult.code == '0') {
|
||||
await beanTaskList();
|
||||
await $.wait(1000);
|
||||
await ddnc_getTreasureBoxAward(2);
|
||||
if ($.treasureRwardResult.code == '0') {
|
||||
console.log(`领取${treasureBox.taskMainTitle}奖励:${$.treasureRwardResult.waterGram}g水滴`);
|
||||
} else {
|
||||
console.log(`领取${treasureBox.taskMainTitle}奖励失败`);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.log(`${treasureBox.taskMainTitle} 已完成`);
|
||||
}
|
||||
|
||||
}
|
||||
async function predictionFruit() {
|
||||
console.log('开始预测水果成熟时间\n');
|
||||
await initForFarm();
|
||||
await taskInitForFarm();
|
||||
// let waterEveryDayT = $.farmTask.totalWaterTaskInit.totalWaterTaskTimes; //今天到到目前为止,浇了多少次水 (这里返回错误,只显示10次)
|
||||
let waterEveryDayT = $.farmTask.firstWaterInit.totalWaterTimes; //今天到到目前为止,浇了多少次水
|
||||
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`
|
||||
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)) {
|
||||
@ -255,7 +305,7 @@ async function predictionFruit() {
|
||||
|
||||
let waterD = Math.ceil(waterTotalT / waterEveryDayT);
|
||||
|
||||
message += `【预测】${waterD === 1 ? '明天' : waterD === 2 ? '后天' : waterD + '天之后'}(${timeFormat(24 * 60 * 60 * 1000 * waterD + Date.now())}日)可兑换水果🍉\n`
|
||||
message += `【预测】${waterD === 1 ? '明天' : waterD === 2 ? '后天' : waterD + '天之后'}(${timeFormat(24 * 60 * 60 * 1000 * waterD + Date.now())}日)可兑换水果🍉`
|
||||
}
|
||||
//浇水十次
|
||||
async function doTenWater() {
|
||||
@ -269,13 +319,14 @@ async function doTenWater() {
|
||||
console.log(`您设置的是使用水滴换豆卡,且背包有水滴换豆卡${beanCard}张, 跳过10次浇水任务`)
|
||||
return
|
||||
}
|
||||
if ($.farmTask.firstWaterInit.totalWaterTimes < $.farmTask.totalWaterTaskInit.totalWaterTaskLimit) {
|
||||
if ($.farmTask.totalWaterTaskInit.totalWaterTaskTimes < $.farmTask.totalWaterTaskInit.totalWaterTaskLimit) {
|
||||
console.log(`\n准备浇水十次`);
|
||||
let waterCount = 0;
|
||||
isFruitFinished = false;
|
||||
for (; waterCount < $.farmTask.totalWaterTaskInit.totalWaterTaskLimit - $.farmTask.firstWaterInit.totalWaterTimes; waterCount++) {
|
||||
for (; waterCount < $.farmTask.totalWaterTaskInit.totalWaterTaskLimit - $.farmTask.totalWaterTaskInit.totalWaterTaskTimes; waterCount++) {
|
||||
console.log(`第${waterCount + 1}次浇水`);
|
||||
await waterGoodForFarm();
|
||||
await $.wait(2000);
|
||||
console.log(`本次浇水结果: ${JSON.stringify($.waterResult)}`);
|
||||
if ($.waterResult.code === '0') {
|
||||
console.log(`剩余水滴${$.waterResult.totalEnergy}g`);
|
||||
@ -327,7 +378,7 @@ async function getFirstWaterAward() {
|
||||
//领取十次浇水奖励
|
||||
async function getTenWaterAward() {
|
||||
//领取10次浇水奖励
|
||||
if (!$.farmTask.totalWaterTaskInit.f && $.farmTask.firstWaterInit.totalWaterTimes >= $.farmTask.totalWaterTaskInit.totalWaterTaskLimit) {
|
||||
if (!$.farmTask.totalWaterTaskInit.f && $.farmTask.totalWaterTaskInit.totalWaterTaskTimes >= $.farmTask.totalWaterTaskInit.totalWaterTaskLimit) {
|
||||
await totalWaterTaskForFarm();
|
||||
if ($.totalWaterReward.code === '0') {
|
||||
console.log(`【十次浇水奖励】获得${$.totalWaterReward.totalWaterTaskEnergy}g💧\n`);
|
||||
@ -336,9 +387,9 @@ async function getTenWaterAward() {
|
||||
// message += '【十次浇水奖励】领取奖励失败,详询日志\n';
|
||||
console.log(`领取10次浇水奖励结果: ${JSON.stringify($.totalWaterReward)}`);
|
||||
}
|
||||
} else if ($.farmTask.firstWaterInit.totalWaterTimes < $.farmTask.totalWaterTaskInit.totalWaterTaskLimit) {
|
||||
// message += `【十次浇水奖励】任务未完成,今日浇水${$.farmTask.firstWaterInit.totalWaterTimes}次\n`;
|
||||
console.log(`【十次浇水奖励】任务未完成,今日浇水${$.farmTask.firstWaterInit.totalWaterTimes}次\n`);
|
||||
} else if ($.farmTask.totalWaterTaskInit.totalWaterTaskTimes < $.farmTask.totalWaterTaskInit.totalWaterTaskLimit) {
|
||||
// message += `【十次浇水奖励】任务未完成,今日浇水${$.farmTask.totalWaterTaskInit.totalWaterTaskTimes}次\n`;
|
||||
console.log(`【十次浇水奖励】任务未完成,今日浇水${$.farmTask.totalWaterTaskInit.totalWaterTaskTimes}次\n`);
|
||||
}
|
||||
console.log('finished 水果任务完成!');
|
||||
}
|
||||
@ -362,7 +413,7 @@ async function doTenWaterAgain() {
|
||||
}
|
||||
if (signCard > 0) {
|
||||
//使用加签卡
|
||||
for (let i = 0; i < 3; i++) {
|
||||
for (let i = 0; i < new Array(signCard).fill('').length; i++) {
|
||||
await userMyCardForFarm('signCard');
|
||||
console.log(`使用加签卡结果:${JSON.stringify($.userMyCardRes)}`);
|
||||
}
|
||||
@ -387,31 +438,27 @@ async function doTenWaterAgain() {
|
||||
console.log(`您目前水滴:${totalEnergy}g,水滴换豆卡${$.myCardInfoRes.beanCard}张,暂不满足水滴换豆的条件,为您继续浇水`)
|
||||
}
|
||||
}
|
||||
|
||||
if (process.env.FRUIT_FAST_CARD && totalEnergy > 100 && $.myCardInfoRes.fastCard > 0) {
|
||||
//使用快速浇水卡
|
||||
for (let i=0;i<new Array(fastCard).fill('').length;i++){
|
||||
await userMyCardForFarm('fastCard');
|
||||
console.log(`使用快速浇水卡结果:${JSON.stringify($.userMyCardRes)}`);
|
||||
if ($.userMyCardRes.code === '0') {
|
||||
console.log(`已使用快速浇水卡浇水${$.userMyCardRes.waterEnergy}g`);
|
||||
}
|
||||
if ($.userMyCardRes.treeFinished){
|
||||
break;
|
||||
}
|
||||
await $.wait(500);
|
||||
await initForFarm();
|
||||
totalEnergy = $.farmInfo.farmUserPro.totalEnergy;
|
||||
}
|
||||
}
|
||||
// if (totalEnergy > retainWater + 100 && $.myCardInfoRes.fastCard > 0) {
|
||||
// //使用快速浇水卡(每次浇100滴)
|
||||
// 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次的任务)
|
||||
if (totalEnergy < retainWater) {
|
||||
console.log('保留水滴不足,停止继续浇水')
|
||||
return
|
||||
}
|
||||
let overageEnergy = totalEnergy - retainWater;
|
||||
if (totalEnergy >= ($.farmInfo.farmUserPro.treeTotalEnergy - $.farmInfo.farmUserPro.treeEnergy)) {
|
||||
if (overageEnergy >= ($.farmInfo.farmUserPro.treeTotalEnergy - $.farmInfo.farmUserPro.treeEnergy)) {
|
||||
//如果现有的水滴,大于水果可兑换所需的对滴(也就是把水滴浇完,水果就能兑换了)
|
||||
isFruitFinished = false;
|
||||
for (let i = 0; i < ($.farmInfo.farmUserPro.treeTotalEnergy - $.farmInfo.farmUserPro.treeEnergy) / 10; i++) {
|
||||
await waterGoodForFarm();
|
||||
await $.wait(500);
|
||||
console.log(`本次浇水结果(水果马上就可兑换了): ${JSON.stringify($.waterResult)}`);
|
||||
if ($.waterResult.code === '0') {
|
||||
console.log('\n浇水10g成功\n');
|
||||
@ -537,34 +584,13 @@ async function turntableFarm() {
|
||||
}
|
||||
}
|
||||
}
|
||||
//天天抽奖助力
|
||||
//console.log('开始天天抽奖--好友助力--每人每天只有三次助力机会.')
|
||||
// for (let code of newShareCodes) {
|
||||
// if (code === $.farmInfo.farmUserPro.shareCode) {
|
||||
// console.log('天天抽奖-不能自己给自己助力\n')
|
||||
// continue
|
||||
// }
|
||||
// await lotteryMasterHelp(code);
|
||||
// await $.wait(1000)
|
||||
// // console.log('天天抽奖助力结果',lotteryMasterHelpRes.helpResult)
|
||||
// if ($.lotteryMasterHelpRes.helpResult === undefined) break;
|
||||
// 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}次`)
|
||||
console.log(`---天天抽奖次数----${remainLotteryTimes}次`)
|
||||
//抽奖
|
||||
if (remainLotteryTimes > 0) {
|
||||
console.log('开始抽奖')
|
||||
let lotteryResult = '';
|
||||
for (let i = 0; i < new Array(remainLotteryTimes).fill('').length; i++) {
|
||||
await lotteryForTurntableFarm()
|
||||
await $.wait(500);
|
||||
console.log(`第${i + 1}次抽奖结果${JSON.stringify($.lotteryRes)}`);
|
||||
if ($.lotteryRes.code === '0') {
|
||||
turntableInfos.map((item) => {
|
||||
@ -606,10 +632,9 @@ async function getExtraAward() {
|
||||
for (let key of Object.keys($.farmAssistResult.assistStageList)) {
|
||||
let vo = $.farmAssistResult.assistStageList[key]
|
||||
if (vo.stageStaus === 2) {
|
||||
await receiveStageEnergy();
|
||||
await $.wait(500);
|
||||
await receiveStageEnergy()
|
||||
if ($.receiveStageEnergy.code === "0") {
|
||||
console.log(`成功领取第${Number(key) + 1}段助力奖励:【${$.receiveStageEnergy.amount}】g水`)
|
||||
console.log(`已成功领取第${key + 1}阶段好友助力奖励:【${$.receiveStageEnergy.amount}】g水`)
|
||||
num += $.receiveStageEnergy.amount
|
||||
}
|
||||
}
|
||||
@ -633,7 +658,7 @@ async function getExtraAward() {
|
||||
}
|
||||
let date = new Date(item.time);
|
||||
let time = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate() + ' ' + date.getHours() + ':' + date.getMinutes() + ':' + date.getMinutes();
|
||||
console.log(`【${item.nickName || "匿名用户"}】 在 ${time} 给您助过力`);
|
||||
console.log(`\n京东昵称【${item.nickName || "匿名用户"}】 在 ${time} 给您助过力\n`);
|
||||
})
|
||||
message += `【助力您的好友】${str}\n`;
|
||||
}
|
||||
@ -667,7 +692,7 @@ async function getExtraAward() {
|
||||
}
|
||||
let date = new Date(item.time);
|
||||
let time = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate() + ' ' + date.getHours() + ':' + date.getMinutes() + ':' + date.getMinutes();
|
||||
console.log(`【${item.nickName || "匿名用户"}】 在 ${time} 给您助过力`);
|
||||
console.log(`\n京东昵称【${item.nickName || "匿名用户"}】 在 ${time} 给您助过力\n`);
|
||||
})
|
||||
message += `【助力您的好友】${str}\n`;
|
||||
}
|
||||
@ -675,118 +700,7 @@ async function getExtraAward() {
|
||||
}
|
||||
}
|
||||
}
|
||||
//助力好友
|
||||
async function masterHelpShare() {
|
||||
console.log("开始助力好友");
|
||||
let salveHelpAddWater = 0;
|
||||
let remainTimes = 3; //今日剩余助力次数,默认3次(京东农场每人每天3次助力机会)。
|
||||
let helpSuccessPeoples = ""; //成功助力好友
|
||||
console.log(`格式化后的助力码::${JSON.stringify(newShareCodes)}\n`);
|
||||
|
||||
helpStatisticArr = {}
|
||||
helpStatisticArr['fromCode'] = $.farmInfo.farmUserPro.shareCode
|
||||
helpStatisticArr['codeType'] = codeType;
|
||||
helpStatisticArr['results'] = {};
|
||||
|
||||
helpStatisticStatus = 2
|
||||
helpStatisticRemark = ''
|
||||
for (let code of newShareCodes) {
|
||||
console.log(`开始助力京东账号${$.index} - ${$.nickName || $.UserName}的好友: ${code}`);
|
||||
if (!code) continue;
|
||||
if (code === $.farmInfo.farmUserPro.shareCode) {
|
||||
console.log("不能为自己助力哦,跳过自己的shareCode\n");
|
||||
continue;
|
||||
}
|
||||
// $.helpResult = await doWxApi("initForFarmWX", { shareCode: code, mpin: "", imageUrl: "", nickName: "", version, channel: 2, babelChannel: 0 }, 0);
|
||||
await masterHelp(code);
|
||||
if ($.helpResult.code === "0") {
|
||||
if ($.helpResult.helpResult.code === "0") {
|
||||
//助力成功
|
||||
helpStatisticStatus = 1;
|
||||
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") {
|
||||
helpStatisticStatus = 3;
|
||||
console.log(`【助力好友结果】: 助力【${$.helpResult.helpResult.masterUserInfo.nickName}】失败,您今天助力次数已耗尽`);
|
||||
} else if ($.helpResult.helpResult.code === "9") {
|
||||
helpStatisticStatus = 5;
|
||||
console.log(`【助力好友结果】: 之前给【${$.helpResult.helpResult.masterUserInfo.nickName}】助力过了`);
|
||||
} else if ($.helpResult.helpResult.code === "10") {
|
||||
helpStatisticStatus = 4;
|
||||
console.log(`【助力好友结果】: 好友【${$.helpResult.helpResult.masterUserInfo.nickName}】已满五人助力`);
|
||||
} else {
|
||||
helpStatisticStatus = 6;
|
||||
helpStatisticRemark = JSON.stringify($.helpResult.helpResult)
|
||||
console.log(`助力其他情况:${JSON.stringify($.helpResult.helpResult)}`);
|
||||
}
|
||||
console.log(`【今日助力次数还剩】${$.helpResult.helpResult.remainTimes}次\n`);
|
||||
remainTimes = $.helpResult.helpResult.remainTimes;
|
||||
if ($.helpResult.helpResult.remainTimes === 0) {
|
||||
console.log(`您当前助力次数已耗尽,跳出助力`);
|
||||
if (!(helpStatisticStatus in helpStatisticArr['results'])) {
|
||||
helpStatisticArr['results'][helpStatisticStatus] = [code]
|
||||
} else {
|
||||
helpStatisticArr['results'][helpStatisticStatus].push(code)
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
helpStatisticStatus = 2;
|
||||
helpStatisticRemark = JSON.stringify($.helpResult.helpResult)
|
||||
console.log(`助力失败::${JSON.stringify($.helpResult)}`);
|
||||
}
|
||||
if (!(helpStatisticStatus in helpStatisticArr['results'])) {
|
||||
helpStatisticArr['results'][helpStatisticStatus] = [code]
|
||||
} else {
|
||||
helpStatisticArr['results'][helpStatisticStatus].push(code)
|
||||
}
|
||||
}
|
||||
helpStatisticArr['Remark'] = helpStatisticRemark;
|
||||
console.log(`当前使用助力池${JD_ZLC_URL}`)
|
||||
r = { url: `https://zlc1.chaoyi996.com/api/app/booster-code/submit-real-contribution`, body: JSON.stringify(helpStatisticArr), headers: { "Content-Type": "application/json" } };
|
||||
$.post(r, (err, resp, data) => {
|
||||
try {
|
||||
if (err) {
|
||||
console.log(`${JSON.stringify(err)}`)
|
||||
console.log(`${$.name} 提交助力结果API请求失败`)
|
||||
} else {
|
||||
if (data) {
|
||||
console.log(`提交成功`)
|
||||
data = JSON.parse(data);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
$.logErr(e, resp)
|
||||
}
|
||||
})
|
||||
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`;
|
||||
console.log("助力好友结束,即将开始领取额外水滴奖励\n");
|
||||
}
|
||||
//水滴雨
|
||||
async function executeWaterRains() {
|
||||
let executeWaterRain = !$.farmTask.waterRainInit.f;
|
||||
@ -797,7 +711,7 @@ async function executeWaterRains() {
|
||||
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`);
|
||||
console.log(`【第${$.farmTask.waterRainInit.winTimes + 1}次水滴雨】未到时间,请${new Date($.farmTask.waterRainInit.lastTime + 3 * 60 * 60 * 1000).toLocaleTimeString()}再试\n`);
|
||||
}
|
||||
}
|
||||
if (executeWaterRain) {
|
||||
@ -883,36 +797,7 @@ async function clockInIn() {
|
||||
}
|
||||
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(`开始删除好友 [${friend.shareCode}]`);
|
||||
const deleteFriendForFarm = await request('deleteFriendForFarm', { "shareCode": `${friend.shareCode}`, "version": 8, "channel": 1 });
|
||||
if (deleteFriendForFarm && deleteFriendForFarm.code === '0') {
|
||||
console.log(`删除成功!\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();
|
||||
@ -931,7 +816,8 @@ async function doFriendsWater() {
|
||||
}
|
||||
});
|
||||
console.log(`需要浇水的好友列表shareCodes:${JSON.stringify(needWaterFriends)}`);
|
||||
let waterFriendsCount = 0, cardInfoStr = '';
|
||||
let waterFriendsCount = 0,
|
||||
cardInfoStr = '';
|
||||
for (let index = 0; index < needWaterFriends.length; index++) {
|
||||
await waterFriendForFarm(needWaterFriends[index]);
|
||||
console.log(`为第${index+1}个好友浇水结果:${JSON.stringify($.waterFriendForFarmRes)}\n`)
|
||||
@ -990,30 +876,7 @@ async function getWaterFriendGotAward() {
|
||||
console.log(`暂未给${waterFriendMax}个好友浇水\n`);
|
||||
}
|
||||
}
|
||||
//接收成为对方好友的邀请
|
||||
async function receiveFriendInvite() {
|
||||
for (let code of newShareCodes) {
|
||||
if (code === $.farmInfo.farmUserPro.shareCode) {
|
||||
console.log('自己不能邀请自己成为好友噢\n')
|
||||
continue
|
||||
}
|
||||
await inviteFriend(code);
|
||||
// console.log(`接收邀请成为好友结果:${JSON.stringify($.inviteFriendRes)}`)
|
||||
if ($.inviteFriendRes && $.inviteFriendRes.helpResult && $.inviteFriendRes.helpResult.code === '0') {
|
||||
console.log(`接收邀请成为好友结果成功,您已成为${$.inviteFriendRes.helpResult.masterUserInfo.nickName}的好友`)
|
||||
} else if ($.inviteFriendRes && $.inviteFriendRes.helpResult && $.inviteFriendRes.helpResult.code === '17') {
|
||||
console.log(`接收邀请成为好友结果失败,对方已是您的好友`)
|
||||
}
|
||||
}
|
||||
// console.log(`开始接受6fbd26cc27ac44d6a7fed34092453f77的邀请\n`)
|
||||
// await inviteFriend('6fbd26cc27ac44d6a7fed34092453f77');
|
||||
// console.log(`接收邀请成为好友结果:${JSON.stringify($.inviteFriendRes.helpResult)}`)
|
||||
// if ($.inviteFriendRes.helpResult.code === '0') {
|
||||
// console.log(`您已成为${$.inviteFriendRes.helpResult.masterUserInfo.nickName}的好友`)
|
||||
// } else if ($.inviteFriendRes.helpResult.code === '17') {
|
||||
// console.log(`对方已是您的好友`)
|
||||
// }
|
||||
}
|
||||
|
||||
async function duck() {
|
||||
for (let i = 0; i < 10; i++) {
|
||||
//这里循环十次
|
||||
@ -1039,6 +902,19 @@ async function duck() {
|
||||
}
|
||||
}
|
||||
}
|
||||
async function collect() {
|
||||
try {
|
||||
await initForFarm();
|
||||
if ($.farmInfo.farmUserPro) {
|
||||
console.log(`\n【京东账号${$.index}(${$.UserName})的${$.name}好友互助码】${$.farmInfo.farmUserPro.shareCode}\n`);
|
||||
jdFruitShareArr.push($.farmInfo.farmUserPro.shareCode)
|
||||
} else {
|
||||
//console.log(`初始化农场数据异常, 请登录京东 app查看农场0元水果功能是否正常。`);
|
||||
}
|
||||
} catch (e) {
|
||||
$.logErr(e);
|
||||
}
|
||||
}
|
||||
// ========================API调用接口========================
|
||||
//鸭子,点我有惊喜
|
||||
async function getFullCollectionReward() {
|
||||
@ -1063,7 +939,39 @@ async function getFullCollectionReward() {
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function beanTaskList() {
|
||||
return new Promise(resolve => {
|
||||
const options = {
|
||||
"url": "https://api.m.jd.com/client.action?functionId=beanTaskList",
|
||||
"body": "body=%7B%22viewChannel%22%3A%22AppHome%22%7D&build=167853&client=apple&clientVersion=10.2.0&d_brand=apple&d_model=iPhone11%2C8&ef=1&eid=eidIf12a8121eas2urxgGc%2BzS5%2BUYGu1Nbed7bq8YY%2BgPd0Q0t%2BiviZdQsxnK/HTA7AxZzZBrtu1ulwEviYSV3QUuw2XHHC%2BPFHdNYx1A/3Zt8xYR%2Bd3&ep=%7B%22ciphertype%22%3A5%2C%22cipher%22%3A%7B%22screen%22%3A%22ENS4AtO3EJS%3D%22%2C%22osVersion%22%3A%22CJGkDy4n%22%2C%22openudid%22%3A%22ENq3CzTwENGmYtc3ENSnYtC0DWTwCNdwZNcnZtYmEWU2ZwYnCwY0Cm%3D%3D%22%2C%22area%22%3A%22CJvpCJYmCV81CNS1EP82Ctq1EK%3D%3D%22%2C%22uuid%22%3A%22aQf1ZRdxb2r4ovZ1EJZhcxYlVNZSZz09%22%7D%2C%22ts%22%3A1637625634%2C%22hdid%22%3A%22JM9F1ywUPwflvMIpYPok0tt5k9kW4ArJEU3lfLhxBqw%3D%22%2C%22version%22%3A%221.0.3%22%2C%22appname%22%3A%22com.360buy.jdmobile%22%2C%22ridx%22%3A-1%7D&ext=%7B%22prstate%22%3A%220%22%7D&isBackground=N&joycious=117&lang=zh_CN&networkType=4g&networklibtype=JDNetworkBaseAF&partner=apple&rfs=0000&scope=11&sign=778b3d3d83e0d3f45508a958f306abda&st=1637627411874&sv=101&uemps=0-0&uts=0f31TVRjBSsqndu4/jgUPz6uymy50MQJ1DpIH6AlcMry0eQsMwEN/GgP2FpcEJvoNVODK8ho6G6xfFEYSmOOdwauVOUqIQFPdxhcdWdM05U%2BMN5h6umteQ78SpJGXOymjKiTiGjvSOiTpoqO8k%2BT6stsfe0WS9QQ41HfWeVF6cdpDTzsmufz0XDdJ6CcltPUazK5UqRSuo0UyDMBmw/oWg%3D%3D",
|
||||
"headers": {
|
||||
"Cookie": cookie,
|
||||
"Host": "api.m.jd.com",
|
||||
"Accept": "*/*",
|
||||
"Connection": "keep-alive",
|
||||
"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-Hans-CN;q=1,en-CN;q=0.9",
|
||||
"Accept-Encoding": "gzip,deflate,br",
|
||||
"Content-Type": "application/x-www-form-urlencoded"
|
||||
}
|
||||
}
|
||||
$.post(options, (err, resp, data) => {
|
||||
try {
|
||||
if (err) {
|
||||
console.log(`${JSON.stringify(err)}`)
|
||||
console.log(`${$.name} beanTaskList API请求失败,请检查网路重试`)
|
||||
} else {
|
||||
// console.log('data-----beanTaskList', data)
|
||||
data = $.toObj(data);
|
||||
}
|
||||
} catch (e) {
|
||||
$.logErr(e, resp)
|
||||
} finally {
|
||||
resolve();
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
/**
|
||||
* 领取10次浇水奖励API
|
||||
*/
|
||||
@ -1101,8 +1009,8 @@ async function gotStageAwardForFarm(type) {
|
||||
}
|
||||
//浇水API
|
||||
async function waterGoodForFarm() {
|
||||
await $.wait(1000);
|
||||
console.log('等待了1秒');
|
||||
await $.wait(3000);
|
||||
console.log('等待了3秒');
|
||||
|
||||
const functionId = arguments.callee.name.toString();
|
||||
$.waterResult = await request(functionId);
|
||||
@ -1260,6 +1168,21 @@ async function browseAdTaskForFarm(advertId, type) {
|
||||
$.browseRwardResult = await request(functionId, {advertId, type});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 去首页逛逛“领京豆”API
|
||||
* type为1时, 完成任务
|
||||
* type为2时, 领取任务奖励
|
||||
*/
|
||||
async function ddnc_getTreasureBoxAward(type) {
|
||||
const functionId = arguments.callee.name.toString();
|
||||
const body = {"type":type,"babelChannel":"45","line":"getBean","version":18,"channel":1};
|
||||
if (type === 1) {
|
||||
$.treasureResult = await request(functionId, body);
|
||||
} else if (type === 2) {
|
||||
$.treasureRwardResult = await request(functionId, body);
|
||||
}
|
||||
}
|
||||
// 被水滴砸中API
|
||||
async function gotWaterGoalTaskForFarm() {
|
||||
$.goalResult = await request(arguments.callee.name.toString(), { type: 3 });
|
||||
@ -1273,57 +1196,58 @@ async function signForFarm() {
|
||||
* 初始化农场, 可获取果树及用户信息API
|
||||
*/
|
||||
async function initForFarm() {
|
||||
await $.wait(500);
|
||||
return new Promise(resolve => {
|
||||
const option = {
|
||||
url: `${JD_API_HOST}?functionId=initForFarm`,
|
||||
body: `body=${escape(JSON.stringify({ "version": 4 }))}&appid=wh5&clientVersion=9.1.0`,
|
||||
headers: {
|
||||
"accept": "*/*",
|
||||
"accept-encoding": "gzip, deflate, br",
|
||||
"accept-language": "zh-CN,zh;q=0.9",
|
||||
"cache-control": "no-cache",
|
||||
"cookie": cookie,
|
||||
"origin": "https://home.m.jd.com",
|
||||
"pragma": "no-cache",
|
||||
"referer": "https://home.m.jd.com/myJd/newhome.action",
|
||||
"sec-fetch-dest": "empty",
|
||||
"sec-fetch-mode": "cors",
|
||||
"sec-fetch-site": "same-site",
|
||||
"User-Agent": $.UA,
|
||||
"Content-Type": "application/x-www-form-urlencoded"
|
||||
},
|
||||
timeout: 10000,
|
||||
};
|
||||
$.post(option, (err, resp, data) => {
|
||||
try {
|
||||
if (err) {
|
||||
console.log('\n东东农场: API查询请求失败 ‼️‼️');
|
||||
console.log(JSON.stringify(err));
|
||||
$.logErr(err);
|
||||
} else {
|
||||
if (safeGet(data)) {
|
||||
$.farmInfo = JSON.parse(data)
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
$.logErr(e, resp)
|
||||
} finally {
|
||||
resolve();
|
||||
}
|
||||
})
|
||||
})
|
||||
const functionId = arguments.callee.name.toString();
|
||||
$.farmInfo = await request(functionId, {"babelChannel":"121","sid":"3c52b5f17ab2a42398939a27887eaf8w","version":18,"channel":1});
|
||||
// return new Promise(resolve => {
|
||||
// const option = {
|
||||
// url: `${JD_API_HOST}?functionId=initForFarm`,
|
||||
// body: `body=${escape(JSON.stringify({"version":4}))}&appid=wh5&clientVersion=9.1.0`,
|
||||
// headers: {
|
||||
// "accept": "*/*",
|
||||
// "accept-encoding": "gzip, deflate, br",
|
||||
// "accept-language": "zh-CN,zh;q=0.9",
|
||||
// "cache-control": "no-cache",
|
||||
// "cookie": cookie,
|
||||
// "origin": "https://home.m.jd.com",
|
||||
// "pragma": "no-cache",
|
||||
// "referer": "https://home.m.jd.com/myJd/newhome.action",
|
||||
// "sec-fetch-dest": "empty",
|
||||
// "sec-fetch-mode": "cors",
|
||||
// "sec-fetch-site": "same-site",
|
||||
// "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"),
|
||||
// "Content-Type": "application/x-www-form-urlencoded"
|
||||
// },
|
||||
// timeout: 10000,
|
||||
// };
|
||||
// $.post(option, (err, resp, data) => {
|
||||
// try {
|
||||
// if (err) {
|
||||
// console.log('\n东东农场: API查询请求失败 ‼️‼️');
|
||||
// console.log(JSON.stringify(err));
|
||||
// $.logErr(err);
|
||||
// } else {
|
||||
// if (safeGet(data)) {
|
||||
// $.farmInfo = JSON.parse(data)
|
||||
// }
|
||||
// }
|
||||
// } catch (e) {
|
||||
// $.logErr(e, resp)
|
||||
// } finally {
|
||||
// resolve();
|
||||
// }
|
||||
// })
|
||||
// })
|
||||
}
|
||||
|
||||
// 初始化任务列表API
|
||||
async function taskInitForFarm() {
|
||||
console.log('\n初始化任务列表')
|
||||
const functionId = arguments.callee.name.toString();
|
||||
$.farmTask = await request(functionId, { "version": 14, "channel": 1, "babelChannel": "120" });
|
||||
$.farmTask = await request(functionId, {"version":18,"channel":1,"babelChannel":"121"});
|
||||
}
|
||||
//获取好友列表API
|
||||
async function friendListInitForFarm() {
|
||||
$.friendList = await request('friendListInitForFarm', { "version": 4, "channel": 1 });
|
||||
$.friendList = await request('friendListInitForFarm', {"version": 18,"channel": 1,"babelChannel":"45"});
|
||||
// console.log('aa', aa);
|
||||
}
|
||||
// 领取邀请好友的奖励API
|
||||
@ -1332,7 +1256,7 @@ async function awardInviteFriendForFarm() {
|
||||
}
|
||||
//为好友浇水API
|
||||
async function waterFriendForFarm(shareCode) {
|
||||
const body = { "shareCode": shareCode, "version": 6, "channel": 1 }
|
||||
const body = {"shareCode": shareCode, "version": 18, "channel": 1, "babelChannel":"121"};
|
||||
$.waterFriendForFarmRes = await request('waterFriendForFarm', body);
|
||||
}
|
||||
async function showMsg() {
|
||||
@ -1363,58 +1287,12 @@ 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(code) {
|
||||
return new Promise(async resolve => {
|
||||
console.log(`当前使用助力池${JD_ZLC_URL}`)
|
||||
$.get({ url: JD_ZLC_URL + `/farm?code=` + code, timeout: 10000, }, (err, resp, data) => {
|
||||
try {
|
||||
if (err) {
|
||||
console.log(`${JSON.stringify(err)}`)
|
||||
console.log(`${$.name} API请求失败,请检查网路重试`)
|
||||
} else {
|
||||
if (data) {
|
||||
console.log(`随机取20个码来助力`)
|
||||
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 = [];
|
||||
const readShareCodeRes = await readShareCode($.shareCodesArr[$.index - 1]);
|
||||
if (readShareCodeRes && readShareCodeRes.code === 200) {
|
||||
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') : '';
|
||||
if ($.isNode()) {
|
||||
if (process.env.FRUITSHARECODES) {
|
||||
if (process.env.FRUITSHARECODES.indexOf('\n') > -1) {
|
||||
shareCodes = process.env.FRUITSHARECODES.split('\n');
|
||||
} else {
|
||||
shareCodes = process.env.FRUITSHARECODES.split('&');
|
||||
}
|
||||
}
|
||||
}
|
||||
//IOS等用户直接用NobyDa的jd cookie
|
||||
if ($.isNode()) {
|
||||
Object.keys(jdCookieNode).forEach((item) => {
|
||||
@ -1428,51 +1306,53 @@ function requireConfig() {
|
||||
}
|
||||
console.log(`共${cookiesArr.length}个京东账号\n`)
|
||||
$.shareCodesArr = [];
|
||||
if ($.isNode()) {
|
||||
Object.keys(shareCodes).forEach((item) => {
|
||||
if (shareCodes[item]) {
|
||||
$.shareCodesArr.push(shareCodes[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((resolve) => {
|
||||
return new Promise(async resolve => {
|
||||
const options = {
|
||||
url: 'https://plogin.m.jd.com/cgi-bin/ml/islogin',
|
||||
headers: {
|
||||
"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",
|
||||
"Accept-Language": "zh-cn",
|
||||
"Connection": "keep-alive",
|
||||
"Cookie": cookie,
|
||||
"referer": "https://h5.m.jd.com/",
|
||||
"User-Agent": $.UA,
|
||||
},
|
||||
timeout: 10000
|
||||
"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")
|
||||
}
|
||||
$.get(options, (err, resp, data) => {
|
||||
}
|
||||
$.post(options, (err, resp, data) => {
|
||||
try {
|
||||
if (err) {
|
||||
console.log(`${JSON.stringify(err)}`)
|
||||
console.log(`${$.name} API请求失败,请检查网路重试`)
|
||||
} else {
|
||||
if (data) {
|
||||
data = JSON.parse(data);
|
||||
if (data.islogin === "1") {
|
||||
} else if (data.islogin === "0") {
|
||||
$.isLogin = false;
|
||||
if (data['retcode'] === 13) {
|
||||
$.isLogin = false; //cookie过期
|
||||
return
|
||||
}
|
||||
if (data['retcode'] === 0 && data.base && data.base.nickname) {
|
||||
$.nickName = data.base.nickname;
|
||||
}
|
||||
} else {
|
||||
console.log(`京东服务器返回空数据`)
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
finally {
|
||||
$.logErr(e)
|
||||
} finally {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function request(function_id, body = {}, timeout = 1000) {
|
||||
return new Promise(resolve => {
|
||||
setTimeout(() => {
|
||||
@ -1497,6 +1377,7 @@ function request(function_id, body = {}, timeout = 1000) {
|
||||
}, timeout)
|
||||
})
|
||||
}
|
||||
|
||||
function safeGet(data) {
|
||||
try {
|
||||
if (typeof JSON.parse(data) == "object") {
|
||||
@ -1525,6 +1406,7 @@ function taskUrl(function_id, body = {}) {
|
||||
timeout: 10000
|
||||
}
|
||||
}
|
||||
|
||||
function jsonParse(str) {
|
||||
if (typeof str == "string") {
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user