[京喜农场]

变更 随机助力 API 上报参数
变更 助力 API 参数(修复 ret=1011 错误)
变更 助力码为 JSON 格式(环境变量名未改变,只是格式变更为 JSON )
This commit is contained in:
guyuexuan
2021-01-22 17:12:24 +08:00
parent 2a3a0b1a85
commit 105ee3193f
2 changed files with 96 additions and 23 deletions

View File

@@ -321,12 +321,15 @@ function getJxNc(){
if (safeGet(data)) { if (safeGet(data)) {
data = JSON.parse(data); data = JSON.parse(data);
if (data["ret"] === 0) { if (data["ret"] === 0) {
console.log(`【账号${$.index}${$.nickName || $.UserName})京喜农场助力码】${data.smp}`);
if (data.active) { if (data.active) {
console.log(`【账号${$.index}${$.nickName || $.UserName}京喜农场active】${data.active}`); let shareCodeJson = {
'smp': data.smp,
'active': data.active,
'joinnum': data.joinnum,
};
console.log(`【账号${$.index}${$.nickName || $.UserName})京喜农场】` + JSON.stringify(shareCodeJson));
} else { } else {
console.log( `【账号${$.index}${$.nickName || $.UserName})京喜农场】未选择种子,请先去京喜农场选择种子`); console.log(`【账号${$.index}${$.nickName || $.UserName})京喜农场】未选择种子,请先去京喜农场选择种子`);
} }
} }
} else { } else {

View File

@@ -45,7 +45,7 @@ let currentCookie = ''; // 当前用户 cookie
let tokenNull = {'farm_jstoken': '', 'phoneid': '', 'timestamp': ''}; // 内置一份空的 token let tokenNull = {'farm_jstoken': '', 'phoneid': '', 'timestamp': ''}; // 内置一份空的 token
let tokenArr = []; // 用户 token 数组 let tokenArr = []; // 用户 token 数组
let currentToken = {}; // 当前用户 token let currentToken = {}; // 当前用户 token
const shareCode = '22bd6fbbabbaa770a45ab2607e7a1e8a@197c6094e965fdf3d33621b47719e0b1'; // 内置助力码 let shareCode = ''; // 内置助力码
let jxncShareCodeArr = []; // 用户 助力码 数组 let jxncShareCodeArr = []; // 用户 助力码 数组
let currentShareCode = []; // 当前用户 要助力的助力码 let currentShareCode = []; // 当前用户 要助力的助力码
const openUrl = `openjd://virtual?params=${encodeURIComponent('{ "category": "jump", "des": "m", "url": "https://wqsh.jd.com/sns/201912/12/jxnc/detail.html?ptag=7155.9.32&smp=b47f4790d7b2a024e75279f55f6249b9&active=jdnc_1_chelizi1205_2"}',)}`; // 打开京喜农场 const openUrl = `openjd://virtual?params=${encodeURIComponent('{ "category": "jump", "des": "m", "url": "https://wqsh.jd.com/sns/201912/12/jxnc/detail.html?ptag=7155.9.32&smp=b47f4790d7b2a024e75279f55f6249b9&active=jdnc_1_chelizi1205_2"}',)}`; // 打开京喜农场
@@ -106,9 +106,20 @@ let assistUserShareCode = 0; // 随机助力用户 share code
$.done(); $.done();
}) })
// 检查互助码格式是否为 json
// 成功返回 json 对象,失败返回 ''
function changeShareCodeJson(code) {
try {
let json = code && JSON.parse(code);
return json['smp'] && json['active'] && json['joinnum'] ? json : '';
} catch (e) {
return '';
}
}
// 加载配置 cookie token shareCode // 加载配置 cookie token shareCode
function requireConfig() { function requireConfig() {
return new Promise(resolve => { return new Promise(async resolve => {
$.log('开始获取配置文件\n') $.log('开始获取配置文件\n')
notify = $.isNode() ? require('./sendNotify') : ''; notify = $.isNode() ? require('./sendNotify') : '';
//Node.js用户请在jdCookie.js处填写京东ck; //Node.js用户请在jdCookie.js处填写京东ck;
@@ -142,13 +153,52 @@ function requireConfig() {
Object.keys(jdJxncShareCodeNode).forEach((item) => { Object.keys(jdJxncShareCodeNode).forEach((item) => {
if (jdJxncShareCodeNode[item]) { if (jdJxncShareCodeNode[item]) {
jxncShareCodeArr.push(jdJxncShareCodeNode[item]) jxncShareCodeArr.push(jdJxncShareCodeNode[item])
} else {
jxncShareCodeArr.push('');
} }
}) })
} }
// console.log(`jdFruitShareArr::${JSON.stringify(jdFruitShareArr)}`) // 检查互助码是否为 json [smp,active,joinnum] 格式,否则进行通知
// console.log(`jdFruitShareArr账号长度::${jdFruitShareArr.length}`) for (let i = 0; i < jxncShareCodeArr.length; i++) {
if (jxncShareCodeArr[i]) {
let tmpjsonShareCodeArr = jxncShareCodeArr.splice('@');
if (!changeShareCodeJson(tmpjsonShareCodeArr[0])) {
$.log('互助码格式已变更,请重新填写互助码');
$.msg($.name, '互助码格式变更通知', '互助码格式变更,请重新填写 ‼️‼️', option);
if ($.isNode()) {
await notify.sendNotify(`${$.name}`, `互助码格式变更,请重新填写 ‼️‼️`);
}
}
break;
}
}
// console.log(`jdFruitShareArr::${JSON.stringify(jxncShareCodeArr)}`)
// console.log(`jdFruitShareArr账号长度::${jxncShareCodeArr.length}`)
$.log(`您提供了${jxncShareCodeArr.length}个账号的京喜农场助力码`); $.log(`您提供了${jxncShareCodeArr.length}个账号的京喜农场助力码`);
try {
let options = {
"url": `https://gitee.com/guyuexuan/jd_share_code/raw/master/share_code/jxnc.json`,
"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",
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36"
},
"timeout": 10000,
}
$.get(options, (err, resp, data) => { // 初始化内置变量
if (!err) {
shareCode = data;
}
});
} catch (e) {
// 获取内置助力码失败
}
resolve() resolve()
}) })
} }
@@ -233,8 +283,12 @@ async function jdJXNC() {
notifyBool = true; notifyBool = true;
message += `【成熟】水果已成熟请及时收取deliverState${startInfo.deliverState}\n`; message += `【成熟】水果已成熟请及时收取deliverState${startInfo.deliverState}\n`;
} else { } else {
$.log(`【京东账号${$.index}${$.nickName || $.UserName})的${$.name}好友互助码】 ${$.info.smp}`); let shareCodeJson = {
$.log(`【京东账号${$.index}${$.nickName || $.UserName})的${$.name}种子active】 ${$.info.active}`); "smp": $.info.smp,
"active": $.info.active,
"joinnum": $.info.joinnum,
};
$.log(`【京东账号${$.index}${$.nickName || $.UserName})的${$.name}好友互助码】` + JSON.stringify(shareCodeJson));
await $.wait(500); await $.wait(500);
const isOk = await browserTask(); const isOk = await browserTask();
if (isOk) { if (isOk) {
@@ -249,10 +303,10 @@ async function jdJXNC() {
if (next) { if (next) {
while ($.helpNum < $.maxHelpNum) { while ($.helpNum < $.maxHelpNum) {
$.helpNum++; $.helpNum++;
assistUserShareCode = await getAssistUser(); assistUserShareCodeJson = await getAssistUser();
if (assistUserShareCode) { if (assistUserShareCodeJson) {
await $.wait(500); await $.wait(500);
next = await helpShareCode(assistUserShareCode); next = await helpShareCode(assistUserShareCodeJson['smp'], assistUserShareCodeJson['active'], assistUserShareCodeJson['joinnum']);
if (next) { if (next) {
await $.wait(1000); await $.wait(1000);
continue; continue;
@@ -420,7 +474,7 @@ function submitInviteId(userName) {
try { try {
$.post( $.post(
{ {
url: `https://api.ninesix.cc/api/jx-nc/${$.info.smp}/${encodeURIComponent(userName)}?active=${$.info.active}`, url: `https://api.ninesix.cc/api/jx-nc/${$.info.smp}/${encodeURIComponent(userName)}?active=${$.info.active}&joinnum=${$.info.joinnum}`,
timeout: 10000 timeout: 10000
}, },
(err, resp, _data) => { (err, resp, _data) => {
@@ -450,10 +504,16 @@ function getAssistUser() {
try { try {
$.get({url: `https://api.ninesix.cc/api/jx-nc?active=${$.info.active}`, timeout: 10000}, async (err, resp, _data) => { $.get({url: `https://api.ninesix.cc/api/jx-nc?active=${$.info.active}`, timeout: 10000}, async (err, resp, _data) => {
try { try {
const {code, data = {}} = JSON.parse(_data); const {code, data: {value, extra = {}} = {}} = JSON.parse(_data);
if (data.value) { if (value && extra.active) { // && extra.joinnum 截止 2021-01-22 16:39:09 API 线上还未部署新的 joinnum 参数代码,暂时默认 1 兼容
$.log(`获取随机助力码成功 ${code} ${data.value}`); let shareCodeJson = {
resolve(data.value); 'smp': value,
'active': extra.active,
'joinnum': extra.joinnum || 1
};
$.log(`获取随机助力码成功 ` + JSON.stringify(shareCodeJson));
resolve(shareCodeJson);
return;
} else { } else {
$.log(`获取随机助力码失败 ${code}`); $.log(`获取随机助力码失败 ${code}`);
} }
@@ -477,7 +537,12 @@ async function helpFriends() {
if (!code) { if (!code) {
continue continue
} }
const next = await helpShareCode(code); let tmpShareCodeJson = changeShareCodeJson(code);
if (!tmpShareCodeJson) { //非 json 格式跳过
console.log('助力码非 json 格式,跳过')
continue;
}
const next = await helpShareCode(tmpShareCodeJson['smp'], tmpShareCodeJson['active'], tmpShareCodeJson['joinnum']);
if (!next) { if (!next) {
return false; return false;
} }
@@ -487,15 +552,15 @@ async function helpFriends() {
} }
// 执行助力 return true 继续助力 false 助力结束 // 执行助力 return true 继续助力 false 助力结束
function helpShareCode(code) { function helpShareCode(smp, active, joinnum) {
return new Promise(async resolve => { return new Promise(async resolve => {
if (code === $.info.smp) { // 自己的助力码,跳过,继续执行 if (smp === $.info.smp) { // 自己的助力码,跳过,继续执行
$.log('助力码与当前账号相同,跳过助力。准备进行下一个助力'); $.log('助力码与当前账号相同,跳过助力。准备进行下一个助力');
resolve(true); resolve(true);
} }
$.log(`即将助力 share code${code}`); $.log(`即将助力 share {"smp":"${smp}","active":"${active}","joinnum":"${joinnum}"}`);
$.get( $.get(
taskUrl('help', `active=${$.info.active}&joinnum=${$.info.joinnum}&smp=${code}`), taskUrl('help', `active=${active}&joinnum=${joinnum}&smp=${smp}`),
async (err, resp, data) => { async (err, resp, data) => {
try { try {
const res = data.match(/try\{whyour\(([\s\S]*)\)\;\}catch\(e\)\{\}/)[1]; const res = data.match(/try\{whyour\(([\s\S]*)\)\;\}catch\(e\)\{\}/)[1];
@@ -506,8 +571,13 @@ function helpShareCode(code) {
// ret=1011 active 不同 // ret=1011 active 不同
if (ret === 0 || ret === 1021 || ret === 1011) { // 0 助力成功 if (ret === 0 || ret === 1021 || ret === 1011) { // 0 助力成功
resolve(true); resolve(true);
return;
} }
// ret 1016 助力上限 // ret 1016 助力上限
// ret 147 filter 当前账号黑号了
if (ret === 147) {
$.log(`\n\n !!!!!!!! 当前账号黑号了 !!!!!!!! \n\n`);
}
} catch (e) { } catch (e) {
$.logErr(e, resp); $.logErr(e, resp);
} finally { } finally {