签到领现金。已支持提供互助码相互帮助,环境变量为JD_CASH_SHARECODES
This commit is contained in:
106
jd_cash.js
106
jd_cash.js
@ -26,7 +26,12 @@ const jdCookieNode = $.isNode() ? require('./jdCookie.js') : '';
|
||||
let jdNotify = true;//是否关闭通知,false打开通知推送,true关闭通知推送
|
||||
//IOS等用户直接用NobyDa的jd cookie
|
||||
let cookiesArr = [], cookie = '', message;
|
||||
let helpAuthor = true
|
||||
let helpAuthor = true;
|
||||
const randomCount = $.isNode() ? 20 : 5;
|
||||
const inviteCodes = [
|
||||
`-4msulYas0O2JsRhE-2TA5XZmBQ@eU9Yar_mb_9z92_WmXNG0w@eU9YaO7jMvwh-W_VzyUX0Q`,
|
||||
`-4msulYas0O2JsRhE-2TA5XZmBQ@eU9Yar_mb_9z92_WmXNG0w@eU9YaO7jMvwh-W_VzyUX0Q`
|
||||
]
|
||||
if ($.isNode()) {
|
||||
Object.keys(jdCookieNode).forEach((item) => {
|
||||
cookiesArr.push(jdCookieNode[item])
|
||||
@ -47,7 +52,7 @@ const JD_API_HOST = 'https://api.m.jd.com/client.action';
|
||||
$.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"});
|
||||
return;
|
||||
}
|
||||
$.newShareCodes = []
|
||||
await requireConfig()
|
||||
await getAuthorShareCode();
|
||||
for (let i = 0; i < cookiesArr.length; i++) {
|
||||
if (cookiesArr[i]) {
|
||||
@ -79,6 +84,7 @@ const JD_API_HOST = 'https://api.m.jd.com/client.action';
|
||||
})
|
||||
async function jdCash() {
|
||||
await index()
|
||||
await shareCodesFormat()
|
||||
await helpFriends()
|
||||
await index(true)
|
||||
// await getReward()
|
||||
@ -104,6 +110,8 @@ function index(info=false) {
|
||||
'inviteCode': data.data.result.inviteCode,
|
||||
'shareDate': data.data.result.shareDate
|
||||
}
|
||||
$.shareDate = data.data.result.shareDate;
|
||||
$.log(`shareDate: ${$.shareDate}`)
|
||||
// console.log(helpInfo)
|
||||
for(let task of data.data.result.taskInfos){
|
||||
if (task.type === 4) {
|
||||
@ -141,14 +149,20 @@ function index(info=false) {
|
||||
}
|
||||
async function helpFriends() {
|
||||
$.canHelp = true
|
||||
if (helpAuthor && $.authorCode) {
|
||||
for(let helpInfo of $.authorCode){
|
||||
console.log(`去帮助好友${helpInfo['inviteCode']}`)
|
||||
await helpFriend(helpInfo)
|
||||
if(!$.canHelp) break
|
||||
await $.wait(1000)
|
||||
}
|
||||
for (let code of $.newShareCodes) {
|
||||
console.log(`去帮助好友${code['inviteCode']}`)
|
||||
await helpFriend(code)
|
||||
if(!$.canHelp) break
|
||||
await $.wait(1000)
|
||||
}
|
||||
// if (helpAuthor && $.authorCode) {
|
||||
// for(let helpInfo of $.authorCode){
|
||||
// console.log(`去帮助好友${helpInfo['inviteCode']}`)
|
||||
// await helpFriend(helpInfo)
|
||||
// if(!$.canHelp) break
|
||||
// await $.wait(1000)
|
||||
// }
|
||||
// }
|
||||
}
|
||||
function helpFriend(helpInfo) {
|
||||
return new Promise((resolve) => {
|
||||
@ -164,6 +178,7 @@ function helpFriend(helpInfo) {
|
||||
console.log(`助力成功,获得${data.data.result.cashStr}`)
|
||||
// console.log(data.data.result.taskInfos)
|
||||
} else if (data.data.bizCode===207){
|
||||
console.log(data.data.bizMsg)
|
||||
$.canHelp = false
|
||||
} else{
|
||||
console.log(data.data.bizMsg)
|
||||
@ -241,7 +256,79 @@ function showMsg() {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
function readShareCode() {
|
||||
console.log(`开始`)
|
||||
return new Promise(async resolve => {
|
||||
$.get({url: `https://code.chiang.fun/api/v1/jd/jdcash/read/${randomCount}/`}, (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 > inviteCodes.length ? (inviteCodes.length - 1) : ($.index - 1);
|
||||
$.newShareCodes = inviteCodes[tempIndex].split('@');
|
||||
$.newShareCodes = [...($.authorCode.map((item, index) => $.authorCode[index] = item['inviteCode'])), ...$.newShareCodes];
|
||||
}
|
||||
const readShareCodeRes = await readShareCode();
|
||||
if (readShareCodeRes && readShareCodeRes.code === 200) {
|
||||
$.newShareCodes = [...new Set([...$.newShareCodes, ...(readShareCodeRes.data || [])])];
|
||||
}
|
||||
$.newShareCodes.map((item, index) => $.newShareCodes[index] = { "inviteCode": item, "shareDate": $.shareDate })
|
||||
console.log(`第${$.index}个京东账号将要助力的好友${JSON.stringify($.newShareCodes)}`)
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
|
||||
function requireConfig() {
|
||||
return new Promise(resolve => {
|
||||
console.log(`开始获取${$.name}配置文件\n`);
|
||||
let shareCodes = [];
|
||||
if ($.isNode()) {
|
||||
if (process.env.JD_CASH_SHARECODES) {
|
||||
if (process.env.JD_CASH_SHARECODES.indexOf('\n') > -1) {
|
||||
shareCodes = process.env.JD_CASH_SHARECODES.split('\n');
|
||||
} else {
|
||||
shareCodes = process.env.JD_CASH_SHARECODES.split('&');
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log(`共${cookiesArr.length}个京东账号\n`);
|
||||
$.shareCodesArr = [];
|
||||
if ($.isNode()) {
|
||||
Object.keys(shareCodes).forEach((item) => {
|
||||
if (shareCodes[item]) {
|
||||
$.shareCodesArr.push(shareCodes[item])
|
||||
}
|
||||
})
|
||||
}
|
||||
console.log(`您提供了${$.shareCodesArr.length}个账号的${$.name}助力码\n`);
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
function taskUrl(functionId, body = {}) {
|
||||
return {
|
||||
url: `${JD_API_HOST}?functionId=${functionId}&body=${escape(JSON.stringify(body))}&appid=CashRewardMiniH5Env&appid=9.1.0`,
|
||||
@ -263,6 +350,7 @@ function getAuthorShareCode() {
|
||||
$.get({url: "https://gitee.com/shylocks/updateTeam/raw/main/jd_cash.json",headers:{
|
||||
"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1 Edg/87.0.4280.88"
|
||||
}}, async (err, resp, data) => {
|
||||
$.authorCode = [];
|
||||
try {
|
||||
if (err) {
|
||||
} else {
|
||||
|
@ -25,7 +25,7 @@ const notify = $.isNode() ? require('./sendNotify') : '';
|
||||
//Node.js用户请在jdCookie.js处填写京东ck;
|
||||
const jdCookieNode = $.isNode() ? require('./jdCookie.js') : '';
|
||||
let helpAuthor=true; // 帮助作者
|
||||
const randomCount = 5;
|
||||
const randomCount = $.isNode() ? 20 : 5;
|
||||
let jdNotify = true; // 是否关闭通知,false打开通知推送,true关闭通知推送
|
||||
//IOS等用户直接用NobyDa的jd cookie
|
||||
let cookiesArr = [], cookie = '', message;
|
||||
|
Reference in New Issue
Block a user