Skip to content

Commit

Permalink
Merge pull request #1 from shufflewzc/main
Browse files Browse the repository at this point in the history
Main
  • Loading branch information
xiaopangzia authored Mar 25, 2022
2 parents b04c434 + 0a0634b commit 217d88c
Show file tree
Hide file tree
Showing 14 changed files with 2,678 additions and 1,420 deletions.
Binary file modified .DS_Store
Binary file not shown.
6 changes: 3 additions & 3 deletions jdCookie.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function SetShareCodesEnv(nameConfig = "", envName = "") {
let rawCodeConfig = {}

// 读取互助码
shareCodeLogPath = `${process.env.QL_DIR}/log/.ShareCode/${nameConfig}.log`
let shareCodeLogPath = `${process.env.QL_DIR}/log/.ShareCode/${nameConfig}.log`
let fs = require('fs')
if (fs.existsSync(shareCodeLogPath)) {
// 因为faker2目前没有自带ini,改用已有的dotenv来解析
Expand All @@ -59,7 +59,7 @@ function SetShareCodesEnv(nameConfig = "", envName = "") {
}

// 解析每个用户的互助码
codes = {}
let codes = {}
Object.keys(rawCodeConfig).forEach(function (key) {
if (key.startsWith(`My${nameConfig}`)) {
codes[key] = rawCodeConfig[key]
Expand Down Expand Up @@ -98,4 +98,4 @@ if (nameConfig && envName) {
SetShareCodesEnv(nameConfig, envName)
} else {
console.debug(`OKYYDS 友情提示:您的脚本正常运行中`)
}
}
138 changes: 106 additions & 32 deletions jd_bean_change.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '';
Expand Down Expand Up @@ -362,24 +363,37 @@ 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)
await cash();

//京喜牧场
if(EnableJxMC){
llgeterror = false;
await requestAlgo();
if(llgeterror){
console.log(`等待10秒后再次尝试...`)
await $.wait(10 * 1000);
await requestAlgo();
}
await JxmcGetRequest();
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
}

Expand Down Expand Up @@ -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 = {
Expand All @@ -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 {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
}
}

Expand Down Expand Up @@ -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
}
}

Expand Down Expand Up @@ -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
}
}

Expand All @@ -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
}
}

Expand Down Expand Up @@ -2423,7 +2492,8 @@ function getGetRequest(type, url) {
return {
url: url,
method: method,
headers: headers
headers: headers,
timeout: 10000
};
}

Expand Down Expand Up @@ -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);
Expand All @@ -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 {
Expand Down Expand Up @@ -2637,7 +2710,8 @@ function taskPetPigUrl(function_id, body) {
'User-Agent': UA,
'Referer': `https://u.jr.jd.com/`,
'Accept-Language': `zh-cn`
}
},
timeout: 10000
}
}

Expand Down
Loading

0 comments on commit 217d88c

Please sign in to comment.