diff --git a/jd_bean_change.js b/jd_bean_change.js index 56416c1..43a1d81 100644 --- a/jd_bean_change.js +++ b/jd_bean_change.js @@ -12,6 +12,7 @@ const notify = $.isNode() ? require('./sendNotify') : ''; const JXUserAgent = $.isNode() ? (process.env.JX_USER_AGENT ? process.env.JX_USER_AGENT : ``) : ``; //Node.js用户请在jdCookie.js处填写京东ck; const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +let NowHour = new Date().getHours(); let allMessage = ''; let allMessage2 = ''; let allReceiveMessage = ''; @@ -362,16 +363,23 @@ if(DisableIndex!=-1){ //东东农场 if (EnableJdFruit) { llgeterror = false; - await getjdfruit(); + if (NowHour > 16) { + await jdfruitRequest('taskInitForFarm', { + "version": 14, + "channel": 1, + "babelChannel": "120" + }); + } + await getjdfruit(); if (llgeterror) { - console.log(`东东农场API查询失败,等待10秒后再次尝试...`) - await $.wait(10 * 1000); + console.log(`东东农场API查询失败,等待10秒后再次尝试...`) + await $.wait(10 * 1000); await getjdfruit(); - } - if (llgeterror) { - console.log(`东东农场API查询失败,有空重启路由器换个IP吧.`) - } - + } + if (llgeterror) { + console.log(`东东农场API查询失败,有空重启路由器换个IP吧.`) + } + } //极速金币 if(EnableJdSpeed) @@ -379,7 +387,13 @@ if(DisableIndex!=-1){ //京喜牧场 if(EnableJxMC){ + llgeterror = false; await requestAlgo(); + if(llgeterror){ + console.log(`等待10秒后再次尝试...`) + await $.wait(10 * 1000); + await requestAlgo(); + } await JxmcGetRequest(); } @@ -890,8 +904,17 @@ async function showMsg() { } if(EnableJDPet){ llPetError=false; - const response = await PetRequest('energyCollect'); - const initPetTownRes = await PetRequest('initPetTown'); + var response =""; + response = await PetRequest('energyCollect'); + if(llPetError) + response = await PetRequest('energyCollect'); + + llPetError=false; + var initPetTownRes = ""; + initPetTownRes = await PetRequest('initPetTown'); + if(llPetError) + initPetTownRes = await PetRequest('initPetTown'); + if(!llPetError && initPetTownRes){ if (initPetTownRes.code === '0' && initPetTownRes.resultCode === '0' && initPetTownRes.message === 'success') { $.petInfo = initPetTownRes.result; @@ -1224,7 +1247,8 @@ function apptaskUrl(functionId = "", body = "") { 'User-Agent': 'JD4iPhone/167774 (iPhone; iOS 14.7.1; Scale/3.00)', 'Accept-Language': 'zh-Hans-CN;q=1', 'Accept-Encoding': 'gzip, deflate, br', - } + }, + timeout: 10000 } } function getSign(functionId, body) { @@ -1269,7 +1293,8 @@ function TotalBean() { headers: { Cookie: cookie, "User-Agent": "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", - } + }, + timeout: 10000 } $.get(options, (err, resp, data) => { try { @@ -1320,6 +1345,7 @@ function TotalBean2() { Host: `wxapp.m.jd.com`, 'User-Agent': `Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.10(0x18000a2a) NetType/WIFI Language/zh_CN`, }, + timeout: 10000 }; $.post(options, (err, resp, data) => { try { @@ -1364,6 +1390,7 @@ function isLoginByX1a0He() { "referer": "https://h5.m.jd.com/", "User-Agent": "jdapp;iPhone;10.1.2;15.0;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", }, + timeout: 10000 } $.get(options, (err, resp, data) => { try { @@ -1611,7 +1638,8 @@ function getCoupon() { 'referer': 'https://wqs.jd.com/', 'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8', 'cookie': cookie - } + }, + timeout: 10000 } $.get(options, async(err, resp, data) => { try { @@ -1759,7 +1787,8 @@ function taskJDZZUrl(functionId, body = {}) { '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', 'Accept-Encoding': 'gzip, deflate, br', - } + }, + timeout: 10000 } } @@ -1803,10 +1832,39 @@ function taskMsPostUrl(function_id, body = {}, extra = '', function_id2) { "referer": "https://h5.m.jd.com/babelDiy/Zeus/2NUvze9e1uWf4amBhe1AV6ynmSuH/index.html", 'Content-Type': 'application/x-www-form-urlencoded', "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"), - } + }, + timeout: 10000 } } +function jdfruitRequest(function_id, body = {}, timeout = 1000) { + return new Promise(resolve => { + setTimeout(() => { + $.get(taskfruitUrl(function_id, body), (err, resp, data) => { + try { + if (err) { + console.log('\n东东农场: API查询请求失败 ‼️‼️') + console.log(JSON.stringify(err)); + console.log(`function_id:${function_id}`) + $.logErr(err); + } else { + if (safeGet(data)) { + data = JSON.parse(data); + $.JDwaterEveryDayT = data.totalWaterTaskInit.totalWaterTaskTimes; + } + } + } catch (e) { + $.logErr(e, resp); + } + finally { + resolve(data); + } + }) + }, timeout) + }) +} + + async function getjdfruit() { return new Promise(resolve => { const option = { @@ -1827,7 +1885,7 @@ async function getjdfruit() { "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, + timeout: 10000 }; $.post(option, (err, resp, data) => { try { @@ -1898,19 +1956,26 @@ function taskPetUrl(function_id, body = {}) { '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"), 'Host': 'api.m.jd.com', 'Content-Type': 'application/x-www-form-urlencoded', - } + }, + timeout: 10000 }; } function taskfruitUrl(function_id, body = {}) { - return { - url: `${JD_API_HOST}?functionId=${function_id}&appid=wh5&body=${escape(JSON.stringify(body))}`, - headers: { - Cookie: cookie, - UserAgent: $.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"), - }, - timeout: 10000, - } + return { + url: `${JD_API_HOST}?functionId=${function_id}&body=${encodeURIComponent(JSON.stringify(body))}&appid=wh5`, + headers: { + "Host": "api.m.jd.com", + "Accept": "*/*", + "Origin": "https://carry.m.jd.com", + "Accept-Encoding": "gzip, deflate, br", + "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,zh-Hans;q=0.9", + "Referer": "https://carry.m.jd.com/", + "Cookie": cookie + }, + timeout: 10000 + } } function safeGet(data) { @@ -1976,7 +2041,8 @@ function taskcashUrl(_0x7683x2, _0x7683x3 = {}) { 'user-agent': __Oxb24bc[0x10], 'accept-language': __Oxb24bc[0x11], 'Cookie': cookie - } + }, + timeout: 10000 } } (function (_0x7683x9, _0x7683xa, _0x7683xb, _0x7683xc, _0x7683xd, _0x7683xe) { @@ -2124,7 +2190,8 @@ function jxTaskurl(functionId, body = '', stk) { 'Accept-Language': 'zh-cn', 'Referer': 'https://wqsd.jd.com/pingou/dream_factory/index.html', 'Accept-Encoding': 'gzip, deflate, br', - } + }, + timeout: 10000 } } @@ -2235,7 +2302,7 @@ function ddFactoryTaskUrl(function_id, body = {}, function_id2) { "Referer": "https://h5.m.jd.com/babelDiy/Zeus/2uSsV2wHEkySvompfjB43nuKkcHp/index.html", "User-Agent": "jdapp;iPhone;9.3.4;14.3;88732f840b77821b345bf07fd71f609e6ff12f43;network/4g;ADID/1C141FDD-C62F-425B-8033-9AAB7E4AE6A3;supportApplePay/0;hasUPPay/0;hasOCPay/0;model/iPhone11,8;addressid/2005183373;supportBestPay/0;appBuild/167502;jdSupportDarkMode/0;pv/414.19;apprpd/Babel_Native;ref/TTTChannelViewContoller;psq/5;ads/;psn/88732f840b77821b345bf07fd71f609e6ff12f43|1701;jdv/0|iosapp|t_335139774|appshare|CopyURL|1610885480412|1610885486;adk/;app_device/IOS;pap/JA2015_311210|9.3.4|IOS 14.3;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", }, - timeout: 10000, + timeout: 10000 } } @@ -2272,7 +2339,8 @@ function taskPostClientActionUrl(body) { 'Origin': 'https://joypark.jd.com', 'Referer': 'https://joypark.jd.com/?activityId=LsQNxL7iWDlXUs6cFl-AAg&lng=113.387899&lat=22.512678&sid=4d76080a9da10fbb31f5cd43396ed6cw&un_area=19_1657_52093_0', 'Cookie': cookie, - } + }, + timeout: 10000 } } @@ -2296,7 +2364,8 @@ function taskJxUrl(functionId, body = '') { "Accept-Language": "zh-CN,zh-Hans;q=0.9", "Referer": "https://st.jingxi.com/", "Cookie": cookie - } + }, + timeout: 10000 } } @@ -2423,7 +2492,8 @@ function getGetRequest(type, url) { return { url: url, method: method, - headers: headers + headers: headers, + timeout: 10000 }; } @@ -2514,6 +2584,7 @@ async function requestAlgo() { if (err) { console.log(`${JSON.stringify(err)}`) console.log(`request_algo 签名参数API请求失败,请检查网路重试`) + llgeterror = true; } else { if (data) { data = JSON.parse(data); @@ -2526,10 +2597,12 @@ async function requestAlgo() { console.log('request_algo 签名参数API请求失败:') } } else { + llgeterror = true; console.log(`京东服务器返回空数据`) } } } catch (e) { + llgeterror = true; $.logErr(e, resp) } finally { @@ -2637,7 +2710,8 @@ function taskPetPigUrl(function_id, body) { 'User-Agent': UA, 'Referer': `https://u.jr.jd.com/`, 'Accept-Language': `zh-cn` - } + }, + timeout: 10000 } } diff --git a/jd_plantBean_Mod.js b/jd_plantBean_Mod.js index 31517cc..d0eb610 100644 --- a/jd_plantBean_Mod.js +++ b/jd_plantBean_Mod.js @@ -1,6 +1,6 @@ /* 种豆得豆 脚本更新地址:https://raw.githubusercontent.com/Aaron-lv/sync/jd_scripts/jd_plantBean.js -更新时间:2021-08-20 +更新时间:2022-03-19 活动入口:京东APP我的-更多工具-种豆得豆 已支持IOS京东多账号,云端多京东账号 脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js @@ -8,8 +8,6 @@ 互助码shareCode请先手动运行脚本查看打印可看到 每个京东账号每天只能帮助3个人。多出的助力码将会助力失败。 -// zero205:已添加自己账号内部互助,有剩余助力次数再帮我助力 - =====================================Quantumult X================================= [task_local] 1 7-21/2 * * * https://raw.githubusercontent.com/Aaron-lv/sync/jd_scripts/jd_plantBean.js, tag=种豆得豆, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jdzd.png, enabled=true @@ -43,6 +41,7 @@ let roundList = []; let awardState = '';//上期活动的京豆是否收取 let randomCount = $.isNode() ? 20 : 5; let num; +let llerror=false; $.newShareCode = []; let NowHour = new Date().getHours(); @@ -113,9 +112,32 @@ async function jdPlantBean() { console.log(`获取任务及基本信息`) await plantBeanIndex(); if ($.plantBeanIndexResult.errorCode === 'PB101') { - console.log(`\n活动太火爆了,还是去买买买吧!\n`) - return + console.log(`\n活动太火爆了,还是去买买买吧!\n`) + return } + if ($.plantBeanIndexResult.errorCode) { + console.log(`获取任务及基本信息出错,10秒后重试\n`) + await $.wait(10000); + await plantBeanIndex(); + if ($.plantBeanIndexResult.errorCode === 'PB101') { + console.log(`\n活动太火爆了,还是去买买买吧!\n`) + return + } + } + if ($.plantBeanIndexResult.errorCode) { + console.log(`获取任务及基本信息出错,30秒后重试\n`) + await $.wait(30000); + await plantBeanIndex(); + if ($.plantBeanIndexResult.errorCode === 'PB101') { + console.log(`\n活动太火爆了,还是去买买买吧!\n`) + return + } + } + if ($.plantBeanIndexResult.errorCode) { + console.log(`获取任务及基本信息失败,活动异常,换个时间再试试吧....`) + console.log("错误代码;"+$.plantBeanIndexResult.errorCode) + return + } for (let i = 0; i < $.plantBeanIndexResult.data.roundList.length; i++) { if ($.plantBeanIndexResult.data.roundList[i].roundState === "2") { num = i @@ -151,7 +173,7 @@ async function jdPlantBean() { } catch (e) { $.logErr(e); const errMsg = `京东账号${$.index} ${$.nickName || $.UserName}\n任务执行异常,请检查执行日志 ‼️‼️`; - // if ($.isNode()) await notify.sendNotify(`${$.name}`, errMsg); + if ($.isNode()) await notify.sendNotify(`${$.name}`, errMsg); $.msg($.name, '', `${errMsg}`) } } @@ -572,29 +594,6 @@ async function helpShare(plantUuid) { async function plantBeanIndex() { $.plantBeanIndexResult = await request('plantBeanIndex');//plantBeanIndexBody } -function readShareCode() { - return new Promise(async resolve => { - $.get({url: `https://api.jdsharecode.xyz/api/bean/${randomCount}`, 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(15000); - resolve() - }) -} //格式化助力码 function shareCodesFormat() { return new Promise(async resolve => {