mirror of https://github.com/KingRan/KR.git
parent
65591a934e
commit
8e08ba8bb3
61
jd_cash.js
61
jd_cash.js
|
@ -8,17 +8,17 @@
|
|||
============Quantumultx===============
|
||||
[task_local]
|
||||
#签到领现金
|
||||
23 0-20/4 * * * jd_cash.js, tag=签到领现金, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true
|
||||
2 0-23/4 * * * jd_cash.js, tag=签到领现金, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true
|
||||
|
||||
================Loon==============
|
||||
[Script]
|
||||
cron "23 0-20/4 * * *" script-path=jd_cash.js,tag=签到领现金
|
||||
cron "2 0-23/4 * * *" script-path=jd_cash.js,tag=签到领现金
|
||||
|
||||
===============Surge=================
|
||||
签到领现金 = type=cron,cronexp="23 0-20/4 * * *",wake-system=1,timeout=3600,script-path=jd_cash.js
|
||||
签到领现金 = type=cron,cronexp="2 0-23/4 * * *",wake-system=1,timeout=3600,script-path=jd_cash.js
|
||||
|
||||
============小火箭=========
|
||||
签到领现金 = type=cron,script-path=jd_cash.js, cronexpr="23 0-20/4 * * *", timeout=3600, enable=true
|
||||
签到领现金 = type=cron,script-path=jd_cash.js, cronexpr="2 0-23/4 * * *", timeout=3600, enable=true
|
||||
*/
|
||||
const $ = new Env('签到领现金');
|
||||
const notify = $.isNode() ? require('./sendNotify') : '';
|
||||
|
@ -49,7 +49,7 @@ let allMessage = '';
|
|||
return;
|
||||
}
|
||||
await requireConfig()
|
||||
$.authorCode = await getAuthorShareCode('')
|
||||
$.authorCode = await getAuthorShareCode('https://gitee.com/KingRan521/JD-Scripts/raw/master/shareCodes/jd_cash.json')
|
||||
for (let i = 0; i < cookiesArr.length; i++) {
|
||||
if (cookiesArr[i]) {
|
||||
cookie = cookiesArr[i];
|
||||
|
@ -90,8 +90,8 @@ async function jdCash() {
|
|||
|
||||
//await shareCodesFormat()
|
||||
// await helpFriends()
|
||||
//await getReward()
|
||||
//await getReward('2');
|
||||
// await getReward()
|
||||
// await getReward('2');
|
||||
$.exchangeBeanNum = 0;
|
||||
cash_exchange = $.isNode() ? (process.env.CASH_EXCHANGE ? process.env.CASH_EXCHANGE : `${cash_exchange}`) : ($.getdata('cash_exchange') ? $.getdata('cash_exchange') : `${cash_exchange}`);
|
||||
// if (cash_exchange === 'true') {
|
||||
|
@ -122,12 +122,10 @@ async function jdCash() {
|
|||
|
||||
async function appindex(info=false) {
|
||||
let functionId = "cash_homePage"
|
||||
let body = "%7B%7D"
|
||||
let uuid = randomString(16)
|
||||
let sign = await getSign(functionId, decodeURIComponent(body), uuid)
|
||||
let url = `${JD_API_HOST}?functionId=${functionId}&build=167774&client=apple&clientVersion=10.1.0&uuid=${uuid}&${sign}`
|
||||
let body = {}
|
||||
let sign = await getSign(functionId, body)
|
||||
return new Promise((resolve) => {
|
||||
$.post(apptaskUrl(url, body), async (err, resp, data) => {
|
||||
$.post(apptaskUrl(functionId, sign), async (err, resp, data) => {
|
||||
try {
|
||||
if (err) {
|
||||
console.log(`${JSON.stringify(err)}`)
|
||||
|
@ -290,12 +288,10 @@ function helpFriend(helpInfo) {
|
|||
|
||||
async function appdoTask(type,taskInfo) {
|
||||
let functionId = 'cash_doTask'
|
||||
let body = escape(JSON.stringify({"type":type,"taskInfo":taskInfo}))
|
||||
let uuid = randomString(16)
|
||||
let sign = await getSign(functionId, decodeURIComponent(body), uuid)
|
||||
let url = `${JD_API_HOST}?functionId=${functionId}&build=167774&client=apple&clientVersion=10.1.0&uuid=${uuid}&${sign}`
|
||||
let body = {"type":type,"taskInfo":taskInfo}
|
||||
let sign = await getSign(functionId, body)
|
||||
return new Promise((resolve) => {
|
||||
$.post(apptaskUrl(url, body), (err, resp, data) => {
|
||||
$.post(apptaskUrl(functionId, sign), (err, resp, data) => {
|
||||
try {
|
||||
if (err) {
|
||||
console.log(`${JSON.stringify(err)}`)
|
||||
|
@ -303,7 +299,7 @@ async function appdoTask(type,taskInfo) {
|
|||
} else {
|
||||
if (safeGet(data)) {
|
||||
data = JSON.parse(data);
|
||||
if( data.code === 0){
|
||||
if(data.code === 0) {
|
||||
console.log(`任务完成成功`)
|
||||
// console.log(data.data.result.taskInfos)
|
||||
} else {
|
||||
|
@ -431,20 +427,21 @@ function exchange2(node) {
|
|||
})
|
||||
})
|
||||
}
|
||||
function getSign(functionid, body, uuid) {
|
||||
function getSign(functionId, body) {
|
||||
return new Promise(async resolve => {
|
||||
let data = {
|
||||
"functionId":functionid,
|
||||
"body":body,
|
||||
"uuid":uuid,
|
||||
functionId,
|
||||
body: JSON.stringify(body),
|
||||
"client":"apple",
|
||||
"clientVersion":"10.1.0"
|
||||
"clientVersion":"10.3.0"
|
||||
}
|
||||
let HostArr = ['jdsign.cf', 'signer.nz.lu']
|
||||
let Host = HostArr[Math.floor((Math.random() * HostArr.length))]
|
||||
let options = {
|
||||
url: `https://cdn.nz.lu/ddo`,
|
||||
body: JSON.stringify(data),
|
||||
headers: {
|
||||
"Host": "jdsign.cf",
|
||||
Host,
|
||||
"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"
|
||||
},
|
||||
timeout: 30 * 1000
|
||||
|
@ -520,10 +517,10 @@ function shareCodesFormat() {
|
|||
let authorCode = deepCopy($.authorCode)
|
||||
$.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 || [])])];
|
||||
}
|
||||
// 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();
|
||||
|
@ -577,10 +574,10 @@ function deepCopy(obj) {
|
|||
return objClone;
|
||||
}
|
||||
|
||||
function apptaskUrl(url, body) {
|
||||
function apptaskUrl(functionId = "", body = "") {
|
||||
return {
|
||||
url,
|
||||
body: `body=${body}`,
|
||||
url: `${JD_API_HOST}?functionId=${functionId}`,
|
||||
body,
|
||||
headers: {
|
||||
'Cookie': cookie,
|
||||
'Host': 'api.m.jd.com',
|
||||
|
@ -595,7 +592,7 @@ function apptaskUrl(url, body) {
|
|||
}
|
||||
function taskUrl(functionId, body = {}) {
|
||||
return {
|
||||
url: `${JD_API_HOST}?functionId=${functionId}&body=${escape(JSON.stringify(body))}&appid=CashRewardMiniH5Env&appid=9.1.0`,
|
||||
url: `${JD_API_HOST}?functionId=${functionId}&body=${encodeURIComponent(JSON.stringify(body))}&appid=CashRewardMiniH5Env&appid=9.1.0`,
|
||||
headers: {
|
||||
'Cookie': cookie,
|
||||
'Host': 'api.m.jd.com',
|
||||
|
|
40
jd_ccSign.js
40
jd_ccSign.js
|
@ -81,12 +81,10 @@ async function jdSign() {
|
|||
|
||||
async function getCouponConfig() {
|
||||
let functionId = `getCouponConfig`
|
||||
let body = escape(JSON.stringify({"childActivityUrl":"openapp.jdmobile://virtual?params={\"category\":\"jump\",\"des\":\"couponCenter\"}","incentiveShowTimes":0,"monitorRefer":"","monitorSource":"ccresource_android_index_config","pageClickKey":"Coupons_GetCenter","rewardShowTimes":0,"sourceFrom":"1"}))
|
||||
let uuid = randomString(16)
|
||||
let sign = await getSign(functionId, decodeURIComponent(body), uuid)
|
||||
let url = `${JD_API_HOST}?functionId=${functionId}&client=android&clientVersion=10.1.2&uuid=${uuid}&${sign}`
|
||||
let body = {"childActivityUrl":"openapp.jdmobile://virtual?params={\"category\":\"jump\",\"des\":\"couponCenter\"}","incentiveShowTimes":0,"monitorRefer":"","monitorSource":"ccresource_android_index_config","pageClickKey":"Coupons_GetCenter","rewardShowTimes":0,"sourceFrom":"1"}
|
||||
let sign = await getSign(functionId, body)
|
||||
return new Promise(async resolve => {
|
||||
$.post(taskUrl(url, body), async (err, resp, data) => {
|
||||
$.post(taskUrl(functionId, sign), async (err, resp, data) => {
|
||||
try {
|
||||
if (err) {
|
||||
console.log(`${JSON.stringify(err)}`)
|
||||
|
@ -101,7 +99,7 @@ async function getCouponConfig() {
|
|||
} else {
|
||||
let pin = await getsecretPin($.UserName)
|
||||
functionId = `ccSignInNecklace`
|
||||
body = escape(JSON.stringify({"childActivityUrl":"openapp.jdmobile://virtual?params={\"category\":\"jump\",\"des\":\"couponCenter\"}","monitorRefer":"appClient","monitorSource":"cc_sign_android_index_config","pageClickKey":"Coupons_GetCenter","sessionId":"","signature":data.result.couponConfig.signNecklaceDomain.signature,"pin":pin,"verifyToken":""}))
|
||||
body = {"childActivityUrl":"openapp.jdmobile://virtual?params={\"category\":\"jump\",\"des\":\"couponCenter\"}","monitorRefer":"appClient","monitorSource":"cc_sign_android_index_config","pageClickKey":"Coupons_GetCenter","sessionId":"","signature":data.result.couponConfig.signNecklaceDomain.signature,"pin":pin,"verifyToken":""}
|
||||
}
|
||||
} else {
|
||||
if (data.result.couponConfig.signNewDomain.roundData.ynSign === '1') {
|
||||
|
@ -109,7 +107,7 @@ async function getCouponConfig() {
|
|||
} else {
|
||||
let pin = await getsecretPin($.UserName)
|
||||
functionId = `ccSignInNew`
|
||||
body = escape(JSON.stringify({"childActivityUrl":"openapp.jdmobile://virtual?params={\"category\":\"jump\",\"des\":\"couponCenter\"}","monitorRefer":"appClient","monitorSource":"cc_sign_android_index_config","pageClickKey":"Coupons_GetCenter","pin":pin}))
|
||||
body = {"childActivityUrl":"openapp.jdmobile://virtual?params={\"category\":\"jump\",\"des\":\"couponCenter\"}","monitorRefer":"appClient","monitorSource":"cc_sign_android_index_config","pageClickKey":"Coupons_GetCenter","pin":pin}
|
||||
}
|
||||
}
|
||||
if (functionId && body) await ccSign(functionId, body)
|
||||
|
@ -124,11 +122,9 @@ async function getCouponConfig() {
|
|||
})
|
||||
}
|
||||
async function ccSign(functionId, body) {
|
||||
let uuid = randomString(16)
|
||||
let sign = await getSign(functionId, decodeURIComponent(body), uuid)
|
||||
let url = `${JD_API_HOST}?functionId=${functionId}&client=android&clientVersion=10.1.2&uuid=${uuid}&${sign}`
|
||||
let sign = await getSign(functionId, body)
|
||||
return new Promise(async resolve => {
|
||||
$.post(taskUrl(url, body), async (err, resp, data) => {
|
||||
$.post(taskUrl(functionId, sign), async (err, resp, data) => {
|
||||
try {
|
||||
if (err) {
|
||||
console.log(`${JSON.stringify(err)}`)
|
||||
|
@ -151,14 +147,13 @@ async function ccSign(functionId, body) {
|
|||
})
|
||||
})
|
||||
}
|
||||
function getSign(functionid, body, uuid) {
|
||||
function getSign(functionId, body) {
|
||||
return new Promise(async resolve => {
|
||||
let data = {
|
||||
"functionId":functionid,
|
||||
"body":body,
|
||||
"uuid":uuid,
|
||||
functionId,
|
||||
body: JSON.stringify(body),
|
||||
"client":"android",
|
||||
"clientVersion":"10.1.2"
|
||||
"clientVersion":"10.3.2"
|
||||
}
|
||||
let HostArr = ['jdsign.cf', 'signer.nz.lu']
|
||||
let Host = HostArr[Math.floor((Math.random() * HostArr.length))]
|
||||
|
@ -231,10 +226,10 @@ function showMsg() {
|
|||
})
|
||||
}
|
||||
|
||||
function taskUrl(url, body) {
|
||||
function taskUrl(functionId, body) {
|
||||
return {
|
||||
url,
|
||||
body: `body=${body}`,
|
||||
url: `${JD_API_HOST}?functionId=${functionId}`,
|
||||
body,
|
||||
headers: {
|
||||
"Host": "api.m.jd.com",
|
||||
"Connection": "keep-alive",
|
||||
|
@ -248,13 +243,6 @@ function taskUrl(url, body) {
|
|||
}
|
||||
}
|
||||
}
|
||||
function randomString(e) {
|
||||
e = e || 32;
|
||||
let t = "abcdefghijklmnopqrstuvwxyz0123456789", a = t.length, n = "";
|
||||
for (let i = 0; i < e; i++)
|
||||
n += t.charAt(Math.floor(Math.random() * a));
|
||||
return n
|
||||
}
|
||||
|
||||
function TotalBean() {
|
||||
return new Promise(async resolve => {
|
||||
|
|
|
@ -40,7 +40,7 @@ let cookiesArr = [], cookie = '', token = '';
|
|||
let UA, UAInfo = {};
|
||||
let nowTimes;
|
||||
const randomCount = $.isNode() ? 20 : 3;
|
||||
$.appId = 10032;
|
||||
$.appId = "92a36";
|
||||
function oc(fn, defaultVal) {//optioanl chaining
|
||||
try {
|
||||
return fn()
|
||||
|
@ -1687,7 +1687,7 @@ async function requestAlgo() {
|
|||
'Accept-Language': 'zh-CN,zh;q=0.9,zh-TW;q=0.8,en;q=0.7'
|
||||
},
|
||||
'body': JSON.stringify({
|
||||
"version": "1.0",
|
||||
"version": "3.0",
|
||||
"fp": $.fingerprint,
|
||||
"appId": $.appId.toString(),
|
||||
"timestamp": Date.now(),
|
||||
|
@ -1750,7 +1750,7 @@ function decrypt(time, stk, type, url) {
|
|||
const hash2 = $.CryptoJS.HmacSHA256(st, hash1.toString()).toString($.CryptoJS.enc.Hex);
|
||||
// console.log(`\nst:${st}`)
|
||||
// console.log(`h5st:${["".concat(timestamp.toString()), "".concat(fingerprint.toString()), "".concat($.appId.toString()), "".concat(token), "".concat(hash2)].join(";")}\n`)
|
||||
return encodeURIComponent(["".concat(timestamp.toString()), "".concat($.fingerprint.toString()), "".concat($.appId.toString()), "".concat($.token), "".concat(hash2)].join(";"))
|
||||
return encodeURIComponent(["".concat(timestamp.toString()), "".concat($.fingerprint.toString()), "".concat($.appId.toString()), "".concat($.token), "".concat(hash2), "".concat("3.0"), "".concat(time)].join(";"))
|
||||
} else {
|
||||
return '20210318144213808;8277529360925161;10001;tk01w952a1b73a8nU0luMGtBanZTHCgj0KFVwDa4n5pJ95T/5bxO/m54p4MtgVEwKNev1u/BUjrpWAUMZPW0Kz2RWP8v;86054c036fe3bf0991bd9a9da1a8d44dd130c6508602215e50bb1e385326779d'
|
||||
}
|
||||
|
|
2023
jd_cfd_help.js
2023
jd_cfd_help.js
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -40,7 +40,7 @@ let cookiesArr = [], cookie = '', token = '';
|
|||
let UA, UAInfo = {};
|
||||
let nowTimes;
|
||||
const randomCount = $.isNode() ? 20 : 3;
|
||||
$.appId = 10032;
|
||||
$.appId = "92a36";
|
||||
if ($.isNode()) {
|
||||
Object.keys(jdCookieNode).forEach((item) => {
|
||||
cookiesArr.push(jdCookieNode[item])
|
||||
|
@ -771,7 +771,7 @@ async function requestAlgo() {
|
|||
'Accept-Language': 'zh-CN,zh;q=0.9,zh-TW;q=0.8,en;q=0.7'
|
||||
},
|
||||
'body': JSON.stringify({
|
||||
"version": "1.0",
|
||||
"version": "3.0",
|
||||
"fp": $.fingerprint,
|
||||
"appId": $.appId.toString(),
|
||||
"timestamp": Date.now(),
|
||||
|
@ -834,7 +834,7 @@ function decrypt(time, stk, type, url) {
|
|||
const hash2 = $.CryptoJS.HmacSHA256(st, hash1.toString()).toString($.CryptoJS.enc.Hex);
|
||||
// console.log(`\nst:${st}`)
|
||||
// console.log(`h5st:${["".concat(timestamp.toString()), "".concat(fingerprint.toString()), "".concat($.appId.toString()), "".concat(token), "".concat(hash2)].join(";")}\n`)
|
||||
return encodeURIComponent(["".concat(timestamp.toString()), "".concat($.fingerprint.toString()), "".concat($.appId.toString()), "".concat($.token), "".concat(hash2)].join(";"))
|
||||
return encodeURIComponent(["".concat(timestamp.toString()), "".concat($.fingerprint.toString()), "".concat($.appId.toString()), "".concat($.token), "".concat(hash2), "".concat("3.0"), "".concat(time)].join(";"))
|
||||
} else {
|
||||
return '20210318144213808;8277529360925161;10001;tk01w952a1b73a8nU0luMGtBanZTHCgj0KFVwDa4n5pJ95T/5bxO/m54p4MtgVEwKNev1u/BUjrpWAUMZPW0Kz2RWP8v;86054c036fe3bf0991bd9a9da1a8d44dd130c6508602215e50bb1e385326779d'
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ if ($.isNode()) {
|
|||
} else {
|
||||
cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item);
|
||||
}
|
||||
$.appId = 10032;
|
||||
$.appId = "92a36";
|
||||
!(async () => {
|
||||
console.log(`\n兑换红包环境变量:export ddwVirHb='1' 请自行设置兑换金额\n`);
|
||||
console.log(`默认红包余额大于0.2元就参与兑换\n`);
|
||||
|
@ -88,7 +88,6 @@ async function perl_auto() {
|
|||
}
|
||||
return flag
|
||||
})
|
||||
await wait()
|
||||
if (!prizes.length) {
|
||||
console.log('无红包满足条件,结束')
|
||||
return
|
||||
|
@ -107,6 +106,7 @@ async function perl_auto() {
|
|||
})
|
||||
}
|
||||
// console.debug('prizes:',prizes)
|
||||
await wait()
|
||||
for (let i = 0; i < prizes.length; i++) {
|
||||
const prize = prizes[i]
|
||||
console.log('兑换面额:', prize.strPrizeName || '随机红包')
|
||||
|
@ -236,65 +236,65 @@ Date.prototype.Format = function (fmt) {
|
|||
}
|
||||
|
||||
async function requestAlgo() {
|
||||
$.fingerprint = await generateFp();
|
||||
const options = {
|
||||
"url": `https://cactus.jd.com/request_algo?g_ty=ajax`,
|
||||
"headers": {
|
||||
'Authority': 'cactus.jd.com',
|
||||
'Pragma': 'no-cache',
|
||||
'Cache-Control': 'no-cache',
|
||||
'Accept': 'application/json',
|
||||
'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',
|
||||
'Content-Type': 'application/json',
|
||||
'Origin': 'https://st.jingxi.com',
|
||||
'Sec-Fetch-Site': 'cross-site',
|
||||
'Sec-Fetch-Mode': 'cors',
|
||||
'Sec-Fetch-Dest': 'empty',
|
||||
'Referer': 'https://st.jingxi.com/',
|
||||
'Accept-Language': 'zh-CN,zh;q=0.9,zh-TW;q=0.8,en;q=0.7'
|
||||
},
|
||||
'body': JSON.stringify({
|
||||
"version": "1.0",
|
||||
"fp": $.fingerprint,
|
||||
"appId": $.appId.toString(),
|
||||
"timestamp": Date.now(),
|
||||
"platform": "web",
|
||||
"expandParams": ""
|
||||
})
|
||||
}
|
||||
return new Promise(async resolve => {
|
||||
$.post(options, (err, resp, data) => {
|
||||
try {
|
||||
if (err) {
|
||||
console.log(`${JSON.stringify(err)}`)
|
||||
console.log(`request_algo 签名参数API请求失败,请检查网路重试`)
|
||||
} else {
|
||||
if (data) {
|
||||
// console.log(data);
|
||||
data = JSON.parse(data);
|
||||
if (data['status'] === 200) {
|
||||
$.token = data.data.result.tk;
|
||||
let enCryptMethodJDString = data.data.result.algo;
|
||||
if (enCryptMethodJDString) $.enCryptMethodJD = new Function(`return ${enCryptMethodJDString}`)();
|
||||
console.log(`获取签名参数成功!`)
|
||||
console.log(`fp: ${$.fingerprint}`)
|
||||
console.log(`token: ${$.token}`)
|
||||
console.log(`enCryptMethodJD: ${enCryptMethodJDString}`)
|
||||
} else {
|
||||
console.log(`fp: ${$.fingerprint}`)
|
||||
console.log('request_algo 签名参数API请求失败:')
|
||||
$.fingerprint = await generateFp();
|
||||
const options = {
|
||||
"url": `https://cactus.jd.com/request_algo?g_ty=ajax`,
|
||||
"headers": {
|
||||
'Authority': 'cactus.jd.com',
|
||||
'Pragma': 'no-cache',
|
||||
'Cache-Control': 'no-cache',
|
||||
'Accept': 'application/json',
|
||||
'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',
|
||||
'Content-Type': 'application/json',
|
||||
'Origin': 'https://st.jingxi.com',
|
||||
'Sec-Fetch-Site': 'cross-site',
|
||||
'Sec-Fetch-Mode': 'cors',
|
||||
'Sec-Fetch-Dest': 'empty',
|
||||
'Referer': 'https://st.jingxi.com/',
|
||||
'Accept-Language': 'zh-CN,zh;q=0.9,zh-TW;q=0.8,en;q=0.7'
|
||||
},
|
||||
'body': JSON.stringify({
|
||||
"version": "3.0",
|
||||
"fp": $.fingerprint,
|
||||
"appId": $.appId.toString(),
|
||||
"timestamp": Date.now(),
|
||||
"platform": "web",
|
||||
"expandParams": ""
|
||||
})
|
||||
}
|
||||
return new Promise(async resolve => {
|
||||
$.post(options, (err, resp, data) => {
|
||||
try {
|
||||
if (err) {
|
||||
console.log(`${JSON.stringify(err)}`)
|
||||
console.log(`request_algo 签名参数API请求失败,请检查网路重试`)
|
||||
} else {
|
||||
if (data) {
|
||||
// console.log(data);
|
||||
data = JSON.parse(data);
|
||||
if (data['status'] === 200) {
|
||||
$.token = data.data.result.tk;
|
||||
let enCryptMethodJDString = data.data.result.algo;
|
||||
if (enCryptMethodJDString) $.enCryptMethodJD = new Function(`return ${enCryptMethodJDString}`)();
|
||||
console.log(`获取签名参数成功!`)
|
||||
console.log(`fp: ${$.fingerprint}`)
|
||||
console.log(`token: ${$.token}`)
|
||||
console.log(`enCryptMethodJD: ${enCryptMethodJDString}`)
|
||||
} else {
|
||||
console.log(`fp: ${$.fingerprint}`)
|
||||
console.log('request_algo 签名参数API请求失败:')
|
||||
}
|
||||
} else {
|
||||
console.log(`京东服务器返回空数据`)
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
$.logErr(e, resp)
|
||||
} finally {
|
||||
resolve();
|
||||
}
|
||||
} else {
|
||||
console.log(`京东服务器返回空数据`)
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
$.logErr(e, resp)
|
||||
} finally {
|
||||
resolve();
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
function decrypt(time, stk, type, url) {
|
||||
stk = stk || (url ? getUrlData(url, '_stk') : '')
|
||||
|
@ -317,10 +317,11 @@ function decrypt(time, stk, type, url) {
|
|||
const hash2 = $.CryptoJS.HmacSHA256(st, hash1.toString()).toString($.CryptoJS.enc.Hex);
|
||||
// console.log(`\nst:${st}`)
|
||||
// console.log(`h5st:${["".concat(timestamp.toString()), "".concat(fingerprint.toString()), "".concat($.appId.toString()), "".concat(token), "".concat(hash2)].join(";")}\n`)
|
||||
return encodeURIComponent(["".concat(timestamp.toString()), "".concat($.fingerprint.toString()), "".concat($.appId.toString()), "".concat($.token), "".concat(hash2)].join(";"))
|
||||
} else {
|
||||
return '20210318144213808;8277529360925161;10001;tk01w952a1b73a8nU0luMGtBanZTHCgj0KFVwDa4n5pJ95T/5bxO/m54p4MtgVEwKNev1u/BUjrpWAUMZPW0Kz2RWP8v;86054c036fe3bf0991bd9a9da1a8d44dd130c6508602215e50bb1e385326779d'
|
||||
}
|
||||
// return encodeURIComponent(["".concat(timestamp.toString()), "".concat($.fingerprint.toString()), "".concat($.appId.toString()), "".concat($.token), "".concat(hash2)].join(";"))
|
||||
return encodeURIComponent(["".concat(timestamp.toString()), "".concat($.fingerprint.toString()), "".concat($.appId.toString()), "".concat($.token), "".concat(hash2), "".concat("3.0"), "".concat(time)].join(";"))
|
||||
} else {
|
||||
return '20210318144213808;8277529360925161;10001;tk01w952a1b73a8nU0luMGtBanZTHCgj0KFVwDa4n5pJ95T/5bxO/m54p4MtgVEwKNev1u/BUjrpWAUMZPW0Kz2RWP8v;86054c036fe3bf0991bd9a9da1a8d44dd130c6508602215e50bb1e385326779d'
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
323
jd_cleancart.js
323
jd_cleancart.js
|
@ -1,77 +1,97 @@
|
|||
/*
|
||||
* @Author: X1a0He
|
||||
* @Contact: https://t.me/X1a0He
|
||||
* @Date: 2021-09-05 23:20:00
|
||||
* @LastEditTime: 2021-09-05 23:20:00
|
||||
* @LastEditors: X1a0He
|
||||
* @Description: 清空购物车,支持环境变量设置关键字,用@分隔,使用前请认真看对应注释
|
||||
[task_local]
|
||||
#清空购物车
|
||||
20 0 * * * jd_cart_remove.js, tag=清空购物车, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true
|
||||
## 清空购物车
|
||||
export JD_CART="true"
|
||||
* @Github: https://github.com/X1a0He/jd_scripts_fixed
|
||||
* 清空购物车,支持环境变量设置关键字,用@分隔,使用前请认真看对应注释
|
||||
* 由于不是用app来进行购物车删除,所以可能会出现部分购物车数据无法删除的问题,例如预购商品,属于正常
|
||||
*/
|
||||
const $ = new Env('清空购物车');
|
||||
//Node.js用户请在jdCookie.js处填写京东ck;
|
||||
const jdCookieNode = $.isNode() ? require('./jdCookie.js') : '';
|
||||
const notify = $.isNode() ? require('./sendNotify') : '';
|
||||
//IOS等用户直接用NobyDa的jd cookie
|
||||
let cookiesArr = [], cookie = '', postBody = '', venderCart;
|
||||
if($.isNode()){
|
||||
let cookiesArr = [], cookie = '', postBody = '', venderCart, error = false;
|
||||
let args_xh = {
|
||||
/*
|
||||
* 跳过某个指定账号,默认为全部账号清空
|
||||
* 填写规则:例如当前Cookie1为pt_key=key; pt_pin=pin1;则环境变量填写pin1即可,此时pin1的购物车将不会被清空
|
||||
* 若有更多,则按照pin1@pin2@pin3进行填写
|
||||
* 环境变量名称:XH_CLEAN_EXCEPT
|
||||
*/
|
||||
except: process.env.XH_CLEAN_EXCEPT && process.env.XH_CLEAN_EXCEPT.split('@') || [],
|
||||
/*
|
||||
* 控制脚本是否执行,设置为true时才会执行删除购物车
|
||||
* 环境变量名称:JD_CART
|
||||
*/
|
||||
clean: process.env.JD_CART === 'true' || true,
|
||||
/*
|
||||
* 控制脚本运行一次取消多少条购物车数据,为0则不删除,默认为100
|
||||
* 环境变量名称:XH_CLEAN_REMOVESIZE
|
||||
*/
|
||||
removeSize: process.env.XH_CLEAN_REMOVESIZE * 1 || 100,
|
||||
/*
|
||||
* 关键字/关键词设置,当购物车商品标题包含关键字/关键词时,跳过该条数据,多个则用@分隔,例如 旺仔牛奶@红外线@紫光
|
||||
* 环境变量名称:XH_CLEAN_KEYWORDS
|
||||
*/
|
||||
keywords: process.env.XH_CLEAN_KEYWORDS && process.env.XH_CLEAN_KEYWORDS.split('@') || [],
|
||||
}
|
||||
console.log('使用前请确保你认真看了注释,看完注释有问题就带着你的问题来找我')
|
||||
console.log('tg: https://t.me/X1a0He')
|
||||
console.log('=====环境变量配置如下=====')
|
||||
console.log(`except: ${typeof args_xh.except}, ${args_xh.except}`)
|
||||
console.log(`clean: ${typeof args_xh.clean}, ${args_xh.clean}`)
|
||||
console.log(`removeSize: ${typeof args_xh.removeSize}, ${args_xh.removeSize}`)
|
||||
console.log(`keywords: ${typeof args_xh.keywords}, ${args_xh.keywords}`)
|
||||
console.log('=======================')
|
||||
console.log()
|
||||
if ($.isNode()) {
|
||||
Object.keys(jdCookieNode).forEach((item) => {
|
||||
cookiesArr.push(jdCookieNode[item])
|
||||
})
|
||||
if(process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {};
|
||||
} else {
|
||||
cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item);
|
||||
}
|
||||
//购物车内容
|
||||
$.cart = process.env.JD_CART === 'true'; // 当环境变量中存在JD_CART并设置为true时才会执行删除购物车
|
||||
let removeSize = process.env.JD_CART_REMOVESIZE || 20; // 运行一次取消多全部已关注的商品。数字0表示不取关任何商品
|
||||
let isRemoveAll = process.env.JD_CART_REMOVEALL || true; //是否清空,如果为false,则上面设置了多少就只删除多少条
|
||||
$.keywords = process.env.JD_CART_KEYWORDS || []
|
||||
$.keywordsNum = 0;
|
||||
!(async() => {
|
||||
console.log('使用前请确保你认真看了注释')
|
||||
console.log('看完注释有问题就带着你的问题来找我')
|
||||
console.log('tg: https://t.me/X1a0He')
|
||||
if($.cart){
|
||||
if(!cookiesArr[0]){
|
||||
if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { };
|
||||
} else cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item);
|
||||
!(async () => {
|
||||
if (args_xh.clean) {
|
||||
if (!cookiesArr[0]) {
|
||||
$.msg('【京东账号一】移除购物车失败', '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {
|
||||
"open-url": "https://bean.m.jd.com/bean/signIndex.action"
|
||||
});
|
||||
}
|
||||
for(let i = 0; i < cookiesArr.length; i++){
|
||||
if(cookiesArr[i]){
|
||||
for (let i = 0; i < cookiesArr.length; i++) {
|
||||
if (cookiesArr[i]) {
|
||||
cookie = cookiesArr[i];
|
||||
$.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1])
|
||||
$.index = i + 1;
|
||||
$.isLogin = true;
|
||||
$.nickName = '';
|
||||
$.error = false;
|
||||
await TotalBean();
|
||||
console.log(`****开始【京东账号${$.index}】${$.nickName || $.UserName}*****`);
|
||||
if(!$.isLogin){
|
||||
console.log(`****开始【京东账号${$.index}】${$.nickName || $.UserName}****`);
|
||||
if (args_xh.except.includes($.UserName)) {
|
||||
console.log(`跳过账号:${$.nickName || $.UserName}`)
|
||||
continue
|
||||
}
|
||||
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"
|
||||
});
|
||||
if($.isNode()){
|
||||
if ($.isNode()) {
|
||||
await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`);
|
||||
}
|
||||
continue
|
||||
}
|
||||
await requireConfig();
|
||||
if (args_xh.removeSize === 0) continue;
|
||||
do {
|
||||
await getCart_xh();
|
||||
$.keywordsNum = 0
|
||||
if($.beforeRemove !== "0"){
|
||||
if ($.beforeRemove !== "0") {
|
||||
await cartFilter_xh(venderCart);
|
||||
if(parseInt($.beforeRemove) !== $.keywordsNum) await removeCart();
|
||||
if (parseInt($.beforeRemove) !== $.keywordsNum) await removeCart();
|
||||
else {
|
||||
console.log('由于购物车内的商品均包含关键字,本次执行将不删除购物车数据')
|
||||
console.log('\n由于购物车内的商品均包含关键字,本次执行将不删除购物车数据')
|
||||
break;
|
||||
}
|
||||
} else break;
|
||||
} while(isRemoveAll && $.keywordsNum !== $.beforeRemove)
|
||||
} while (!$.error && $.keywordsNum !== parseInt($.beforeRemove))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -83,7 +103,7 @@ $.keywordsNum = 0;
|
|||
$.done();
|
||||
})
|
||||
|
||||
function getCart_xh(){
|
||||
function getCart_xh() {
|
||||
console.log('正在获取购物车数据...')
|
||||
return new Promise((resolve) => {
|
||||
const option = {
|
||||
|
@ -93,9 +113,9 @@ function getCart_xh(){
|
|||
"User-Agent": "jdapp;JD4iPhone/167724 (iPhone; iOS 15.0; Scale/3.00)",
|
||||
},
|
||||
}
|
||||
$.get(option, async(err, resp, data) => {
|
||||
try{
|
||||
let content = getSubstr(data, "window.cartData = ", "window._PFM_TIMING").replace(/\s*/g,"");
|
||||
$.get(option, async (err, resp, data) => {
|
||||
try {
|
||||
let content = getSubstr(data, "window.cartData = ", "window._PFM_TIMING").replace(/\s*/g, "");
|
||||
data = JSON.parse(content);
|
||||
$.areaId = data.areaId; // locationId的传值
|
||||
$.traceId = data.traceId; // traceid的传值
|
||||
|
@ -103,41 +123,41 @@ function getCart_xh(){
|
|||
postBody = 'pingouchannel=0&commlist=';
|
||||
$.beforeRemove = data.cartJson.num
|
||||
console.log(`获取到购物车数据 ${$.beforeRemove} 条`)
|
||||
} catch(e){
|
||||
} catch (e) {
|
||||
$.logErr(e, resp);
|
||||
} finally{
|
||||
} finally {
|
||||
resolve(data);
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
function cartFilter_xh(cartData){
|
||||
function cartFilter_xh(cartData) {
|
||||
console.log("正在整理数据...")
|
||||
let pid;
|
||||
$.pushed = 0
|
||||
for(let cartJson of cartData){
|
||||
if($.pushed === removeSize) break;
|
||||
for(let sortedItem of cartJson.sortedItems){
|
||||
if($.pushed === removeSize) break;
|
||||
for (let cartJson of cartData) {
|
||||
if ($.pushed === args_xh.removeSize) break;
|
||||
for (let sortedItem of cartJson.sortedItems) {
|
||||
if ($.pushed === args_xh.removeSize) break;
|
||||
pid = typeof (sortedItem.polyItem.promotion) !== "undefined" ? sortedItem.polyItem.promotion.pid : ""
|
||||
for(let product of sortedItem.polyItem.products){
|
||||
if($.pushed === removeSize) break;
|
||||
for (let product of sortedItem.polyItem.products) {
|
||||
if ($.pushed === args_xh.removeSize) break;
|
||||
let mainSkuName = product.mainSku.name
|
||||
$.isKeyword = false
|
||||
$.isPush = true
|
||||
for(let keyword of $.keywords){
|
||||
if(mainSkuName.indexOf(keyword) !== -1){
|
||||
for (let keyword of args_xh.keywords) {
|
||||
if (mainSkuName.indexOf(keyword) !== -1) {
|
||||
$.keywordsNum += 1
|
||||
$.isPush = false
|
||||
$.keyword = keyword;
|
||||
break;
|
||||
} else $.isPush = true
|
||||
}
|
||||
if($.isPush){
|
||||
if ($.isPush) {
|
||||
let skuUuid = product.skuUuid;
|
||||
let mainSkuId = product.mainSku.id
|
||||
if(pid === "") postBody += `${mainSkuId},,1,${mainSkuId},1,,0,skuUuid:${skuUuid}@@useUuid:0$`
|
||||
if (pid === "") postBody += `${mainSkuId},,1,${mainSkuId},1,,0,skuUuid:${skuUuid}@@useUuid:0$`
|
||||
else postBody += `${mainSkuId},,1,${mainSkuId},11,${pid},0,skuUuid:${skuUuid}@@useUuid:0$`
|
||||
$.pushed += 1;
|
||||
} else {
|
||||
|
@ -151,7 +171,7 @@ function cartFilter_xh(cartData){
|
|||
postBody += `&type=0&checked=0&locationid=${$.areaId}&templete=1®=1&scene=0&version=20190418&traceid=${$.traceId}&tabMenuType=1&sceneval=2`
|
||||
}
|
||||
|
||||
function removeCart(){
|
||||
function removeCart() {
|
||||
console.log('正在删除购物车数据...')
|
||||
return new Promise((resolve) => {
|
||||
const option = {
|
||||
|
@ -164,35 +184,35 @@ function removeCart(){
|
|||
"origin": "https://p.m.jd.com/"
|
||||
},
|
||||
}
|
||||
$.post(option, async(err, resp, data) => {
|
||||
try{
|
||||
$.post(option, async (err, resp, data) => {
|
||||
try {
|
||||
data = JSON.parse(data);
|
||||
$.afterRemove = data.cartJson.num
|
||||
if($.afterRemove < $.beforeRemove){
|
||||
if ($.afterRemove < $.beforeRemove) {
|
||||
console.log(`删除成功,当前购物车剩余数据 ${$.afterRemove} 条\n`)
|
||||
$.beforeRemove = $.afterRemove
|
||||
} else {
|
||||
console.log('删除失败')
|
||||
console.log(data.errMsg)
|
||||
isRemoveAll = false;
|
||||
$.error = true;
|
||||
}
|
||||
} catch(e){
|
||||
} catch (e) {
|
||||
$.logErr(e, resp);
|
||||
} finally{
|
||||
} finally {
|
||||
resolve(data);
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
function getSubstr(str, leftStr, rightStr){
|
||||
function getSubstr(str, leftStr, rightStr) {
|
||||
let left = str.indexOf(leftStr);
|
||||
let right = str.indexOf(rightStr, left);
|
||||
if(left < 0 || right < left) return '';
|
||||
if (left < 0 || right < left) return '';
|
||||
return str.substring(left + leftStr.length, right);
|
||||
}
|
||||
|
||||
function TotalBean(){
|
||||
function TotalBean() {
|
||||
return new Promise(async resolve => {
|
||||
const options = {
|
||||
"url": `https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2`,
|
||||
|
@ -208,18 +228,18 @@ function TotalBean(){
|
|||
}
|
||||
}
|
||||
$.post(options, (err, resp, data) => {
|
||||
try{
|
||||
if(err){
|
||||
try {
|
||||
if (err) {
|
||||
console.log(`${JSON.stringify(err)}`)
|
||||
console.log(`${$.name} API请求失败,请检查网路重试`)
|
||||
} else {
|
||||
if(data){
|
||||
if (data) {
|
||||
data = JSON.parse(data);
|
||||
if(data['retcode'] === 13){
|
||||
if (data['retcode'] === 13) {
|
||||
$.isLogin = false; //cookie过期
|
||||
return
|
||||
}
|
||||
if(data['retcode'] === 0){
|
||||
if (data['retcode'] === 0) {
|
||||
$.nickName = (data['base'] && data['base'].nickname) || $.UserName;
|
||||
} else {
|
||||
$.nickName = $.UserName
|
||||
|
@ -228,31 +248,20 @@ function TotalBean(){
|
|||
console.log(`京东服务器返回空数据`)
|
||||
}
|
||||
}
|
||||
} catch(e){
|
||||
} catch (e) {
|
||||
$.logErr(e, resp)
|
||||
} finally{
|
||||
} finally {
|
||||
resolve();
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function requireConfig(){
|
||||
return new Promise(resolve => {
|
||||
if($.isNode() && process.env.JD_CART){
|
||||
if(process.env.JD_CART_KEYWORDS){
|
||||
$.keywords = process.env.JD_CART_KEYWORDS.split('@')
|
||||
}
|
||||
}
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
|
||||
function jsonParse(str){
|
||||
if(typeof str == "string"){
|
||||
try{
|
||||
function jsonParse(str) {
|
||||
if (typeof str == "string") {
|
||||
try {
|
||||
return JSON.parse(str);
|
||||
} catch(e){
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
$.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie')
|
||||
return [];
|
||||
|
@ -261,15 +270,15 @@ function jsonParse(str){
|
|||
}
|
||||
|
||||
// prettier-ignore
|
||||
function Env(t, e){
|
||||
function Env(t, e) {
|
||||
"undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0);
|
||||
|
||||
class s{
|
||||
constructor(t){
|
||||
class s {
|
||||
constructor(t) {
|
||||
this.env = t
|
||||
}
|
||||
|
||||
send(t, e = "GET"){
|
||||
send(t, e = "GET") {
|
||||
t = "string" == typeof t ? {
|
||||
url: t
|
||||
} : t;
|
||||
|
@ -281,70 +290,70 @@ function Env(t, e){
|
|||
})
|
||||
}
|
||||
|
||||
get(t){
|
||||
get(t) {
|
||||
return this.send.call(this.env, t)
|
||||
}
|
||||
|
||||
post(t){
|
||||
post(t) {
|
||||
return this.send.call(this.env, t, "POST")
|
||||
}
|
||||
}
|
||||
|
||||
return new class{
|
||||
constructor(t, e){
|
||||
return new class {
|
||||
constructor(t, e) {
|
||||
this.name = t, this.http = new s(this), this.data = null, this.dataFile = "box.dat", this.logs = [], this.isMute = !1, this.isNeedRewrite = !1, this.logSeparator = "\n", this.startTime = (new Date).getTime(), Object.assign(this, e), this.log("", `🔔${this.name}, 开始!`)
|
||||
}
|
||||
|
||||
isNode(){
|
||||
isNode() {
|
||||
return "undefined" != typeof module && !!module.exports
|
||||
}
|
||||
|
||||
isQuanX(){
|
||||
isQuanX() {
|
||||
return "undefined" != typeof $task
|
||||
}
|
||||
|
||||
isSurge(){
|
||||
isSurge() {
|
||||
return "undefined" != typeof $httpClient && "undefined" == typeof $loon
|
||||
}
|
||||
|
||||
isLoon(){
|
||||
isLoon() {
|
||||
return "undefined" != typeof $loon
|
||||
}
|
||||
|
||||
toObj(t, e = null){
|
||||
try{
|
||||
toObj(t, e = null) {
|
||||
try {
|
||||
return JSON.parse(t)
|
||||
} catch{
|
||||
} catch {
|
||||
return e
|
||||
}
|
||||
}
|
||||
|
||||
toStr(t, e = null){
|
||||
try{
|
||||
toStr(t, e = null) {
|
||||
try {
|
||||
return JSON.stringify(t)
|
||||
} catch{
|
||||
} catch {
|
||||
return e
|
||||
}
|
||||
}
|
||||
|
||||
getjson(t, e){
|
||||
getjson(t, e) {
|
||||
let s = e;
|
||||
const i = this.getdata(t);
|
||||
if(i) try{
|
||||
if (i) try {
|
||||
s = JSON.parse(this.getdata(t))
|
||||
} catch{}
|
||||
} catch { }
|
||||
return s
|
||||
}
|
||||
|
||||
setjson(t, e){
|
||||
try{
|
||||
setjson(t, e) {
|
||||
try {
|
||||
return this.setdata(JSON.stringify(t), e)
|
||||
} catch{
|
||||
} catch {
|
||||
return !1
|
||||
}
|
||||
}
|
||||
|
||||
getScript(t){
|
||||
getScript(t) {
|
||||
return new Promise(e => {
|
||||
this.get({
|
||||
url: t
|
||||
|
@ -352,7 +361,7 @@ function Env(t, e){
|
|||
})
|
||||
}
|
||||
|
||||
runScript(t, e){
|
||||
runScript(t, e) {
|
||||
return new Promise(s => {
|
||||
let i = this.getdata("@chavy_boxjs_userCfgs.httpapi");
|
||||
i = i ? i.replace(/\n/g, "").trim() : i;
|
||||
|
@ -374,28 +383,28 @@ function Env(t, e){
|
|||
}).catch(t => this.logErr(t))
|
||||
}
|
||||
|
||||
loaddata(){
|
||||
if(!this.isNode()) return {};
|
||||
loaddata() {
|
||||
if (!this.isNode()) return {};
|
||||
{
|
||||
this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path");
|
||||
const t = this.path.resolve(this.dataFile),
|
||||
e = this.path.resolve(process.cwd(), this.dataFile),
|
||||
s = this.fs.existsSync(t),
|
||||
i = !s && this.fs.existsSync(e);
|
||||
if(!s && !i) return {};
|
||||
if (!s && !i) return {};
|
||||
{
|
||||
const i = s ? t : e;
|
||||
try{
|
||||
try {
|
||||
return JSON.parse(this.fs.readFileSync(i))
|
||||
} catch(t){
|
||||
} catch (t) {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
writedata(){
|
||||
if(this.isNode()){
|
||||
writedata() {
|
||||
if (this.isNode()) {
|
||||
this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path");
|
||||
const t = this.path.resolve(this.dataFile),
|
||||
e = this.path.resolve(process.cwd(), this.dataFile),
|
||||
|
@ -406,41 +415,41 @@ function Env(t, e){
|
|||
}
|
||||
}
|
||||
|
||||
lodash_get(t, e, s){
|
||||
lodash_get(t, e, s) {
|
||||
const i = e.replace(/\[(\d+)\]/g, ".$1").split(".");
|
||||
let r = t;
|
||||
for(const t of i)
|
||||
if(r = Object(r)[t], void 0 === r) return s;
|
||||
for (const t of i)
|
||||
if (r = Object(r)[t], void 0 === r) return s;
|
||||
return r
|
||||
}
|
||||
|
||||
lodash_set(t, e, s){
|
||||
lodash_set(t, e, s) {
|
||||
return Object(t) !== t ? t : (Array.isArray(e) || (e = e.toString().match(/[^.[\]]+/g) || []), e.slice(0, -1).reduce((t, s, i) => Object(t[s]) === t[s] ? t[s] : t[s] = Math.abs(e[i + 1]) >> 0 == +e[i + 1] ? [] : {}, t)[e[e.length - 1]] = s, t)
|
||||
}
|
||||
|
||||
getdata(t){
|
||||
getdata(t) {
|
||||
let e = this.getval(t);
|
||||
if(/^@/.test(t)){
|
||||
if (/^@/.test(t)) {
|
||||
const [, s, i] = /^@(.*?)\.(.*?)$/.exec(t), r = s ? this.getval(s) : "";
|
||||
if(r) try{
|
||||
if (r) try {
|
||||
const t = JSON.parse(r);
|
||||
e = t ? this.lodash_get(t, i, "") : e
|
||||
} catch(t){
|
||||
} catch (t) {
|
||||
e = ""
|
||||
}
|
||||
}
|
||||
return e
|
||||
}
|
||||
|
||||
setdata(t, e){
|
||||
setdata(t, e) {
|
||||
let s = !1;
|
||||
if(/^@/.test(e)){
|
||||
if (/^@/.test(e)) {
|
||||
const [, i, r] = /^@(.*?)\.(.*?)$/.exec(e), o = this.getval(i),
|
||||
h = i ? "null" === o ? null : o || "{}" : "{}";
|
||||
try{
|
||||
try {
|
||||
const e = JSON.parse(h);
|
||||
this.lodash_set(e, r, t), s = this.setval(JSON.stringify(e), i)
|
||||
} catch(e){
|
||||
} catch (e) {
|
||||
const o = {};
|
||||
this.lodash_set(o, r, t), s = this.setval(JSON.stringify(o), i)
|
||||
}
|
||||
|
@ -448,19 +457,19 @@ function Env(t, e){
|
|||
return s
|
||||
}
|
||||
|
||||
getval(t){
|
||||
getval(t) {
|
||||
return this.isSurge() || this.isLoon() ? $persistentStore.read(t) : this.isQuanX() ? $prefs.valueForKey(t) : this.isNode() ? (this.data = this.loaddata(), this.data[t]) : this.data && this.data[t] || null
|
||||
}
|
||||
|
||||
setval(t, e){
|
||||
setval(t, e) {
|
||||
return this.isSurge() || this.isLoon() ? $persistentStore.write(t, e) : this.isQuanX() ? $prefs.setValueForKey(t, e) : this.isNode() ? (this.data = this.loaddata(), this.data[e] = t, this.writedata(), !0) : this.data && this.data[e] || null
|
||||
}
|
||||
|
||||
initGotEnv(t){
|
||||
initGotEnv(t) {
|
||||
this.got = this.got ? this.got : require("got"), this.cktough = this.cktough ? this.cktough : require("tough-cookie"), this.ckjar = this.ckjar ? this.ckjar : new this.cktough.CookieJar, t && (t.headers = t.headers ? t.headers : {}, void 0 === t.headers.Cookie && void 0 === t.cookieJar && (t.cookieJar = this.ckjar))
|
||||
}
|
||||
|
||||
get(t, e = (() => {})){
|
||||
get(t, e = (() => { })) {
|
||||
t.headers && (delete t.headers["Content-Type"], delete t.headers["Content-Length"]), this.isSurge() || this.isLoon() ? (this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, {
|
||||
"X-Surge-Skip-Scripting": !1
|
||||
})), $httpClient.get(t, (t, s, i) => {
|
||||
|
@ -481,12 +490,12 @@ function Env(t, e){
|
|||
body: o
|
||||
}, o)
|
||||
}, t => e(t))) : this.isNode() && (this.initGotEnv(t), this.got(t).on("redirect", (t, e) => {
|
||||
try{
|
||||
if(t.headers["set-cookie"]){
|
||||
try {
|
||||
if (t.headers["set-cookie"]) {
|
||||
const s = t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();
|
||||
s && this.ckjar.setCookieSync(s, null), e.cookieJar = this.ckjar
|
||||
}
|
||||
} catch(t){
|
||||
} catch (t) {
|
||||
this.logErr(t)
|
||||
}
|
||||
}).then(t => {
|
||||
|
@ -511,13 +520,13 @@ function Env(t, e){
|
|||
}))
|
||||
}
|
||||
|
||||
post(t, e = (() => {})){
|
||||
if(t.body && t.headers && !t.headers["Content-Type"] && (t.headers["Content-Type"] = "application/x-www-form-urlencoded"), t.headers && delete t.headers["Content-Length"], this.isSurge() || this.isLoon()) this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, {
|
||||
post(t, e = (() => { })) {
|
||||
if (t.body && t.headers && !t.headers["Content-Type"] && (t.headers["Content-Type"] = "application/x-www-form-urlencoded"), t.headers && delete t.headers["Content-Length"], this.isSurge() || this.isLoon()) this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, {
|
||||
"X-Surge-Skip-Scripting": !1
|
||||
})), $httpClient.post(t, (t, s, i) => {
|
||||
!t && s && (s.body = i, s.statusCode = s.status), e(t, s, i)
|
||||
});
|
||||
else if(this.isQuanX()) t.method = "POST", this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, {
|
||||
else if (this.isQuanX()) t.method = "POST", this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, {
|
||||
hints: !1
|
||||
})), $task.fetch(t).then(t => {
|
||||
const {
|
||||
|
@ -533,7 +542,7 @@ function Env(t, e){
|
|||
body: o
|
||||
}, o)
|
||||
}, t => e(t));
|
||||
else if(this.isNode()){
|
||||
else if (this.isNode()) {
|
||||
this.initGotEnv(t);
|
||||
const {
|
||||
url: s,
|
||||
|
@ -562,7 +571,7 @@ function Env(t, e){
|
|||
}
|
||||
}
|
||||
|
||||
time(t, e = null){
|
||||
time(t, e = null) {
|
||||
const s = e ? new Date(e) : new Date;
|
||||
let i = {
|
||||
"M+": s.getMonth() + 1,
|
||||
|
@ -574,20 +583,20 @@ function Env(t, e){
|
|||
S: s.getMilliseconds()
|
||||
};
|
||||
/(y+)/.test(t) && (t = t.replace(RegExp.$1, (s.getFullYear() + "").substr(4 - RegExp.$1.length)));
|
||||
for(let e in i) new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? i[e] : ("00" + i[e]).substr(("" + i[e]).length)));
|
||||
for (let e in i) new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? i[e] : ("00" + i[e]).substr(("" + i[e]).length)));
|
||||
return t
|
||||
}
|
||||
|
||||
msg(e = t, s = "", i = "", r){
|
||||
msg(e = t, s = "", i = "", r) {
|
||||
const o = t => {
|
||||
if(!t) return t;
|
||||
if("string" == typeof t) return this.isLoon() ? t : this.isQuanX() ? {
|
||||
if (!t) return t;
|
||||
if ("string" == typeof t) return this.isLoon() ? t : this.isQuanX() ? {
|
||||
"open-url": t
|
||||
} : this.isSurge() ? {
|
||||
url: t
|
||||
} : void 0;
|
||||
if("object" == typeof t){
|
||||
if(this.isLoon()){
|
||||
if ("object" == typeof t) {
|
||||
if (this.isLoon()) {
|
||||
let e = t.openUrl || t.url || t["open-url"],
|
||||
s = t.mediaUrl || t["media-url"];
|
||||
return {
|
||||
|
@ -595,7 +604,7 @@ function Env(t, e){
|
|||
mediaUrl: s
|
||||
}
|
||||
}
|
||||
if(this.isQuanX()){
|
||||
if (this.isQuanX()) {
|
||||
let e = t["open-url"] || t.url || t.openUrl,
|
||||
s = t["media-url"] || t.mediaUrl;
|
||||
return {
|
||||
|
@ -603,7 +612,7 @@ function Env(t, e){
|
|||
"media-url": s
|
||||
}
|
||||
}
|
||||
if(this.isSurge()){
|
||||
if (this.isSurge()) {
|
||||
let e = t.url || t.openUrl || t["open-url"];
|
||||
return {
|
||||
url: e
|
||||
|
@ -611,26 +620,26 @@ function Env(t, e){
|
|||
}
|
||||
}
|
||||
};
|
||||
if(this.isMute || (this.isSurge() || this.isLoon() ? $notification.post(e, s, i, o(r)) : this.isQuanX() && $notify(e, s, i, o(r))), !this.isMuteLog){
|
||||
if (this.isMute || (this.isSurge() || this.isLoon() ? $notification.post(e, s, i, o(r)) : this.isQuanX() && $notify(e, s, i, o(r))), !this.isMuteLog) {
|
||||
let t = ["", "==============📣系统通知📣=============="];
|
||||
t.push(e), s && t.push(s), i && t.push(i), console.log(t.join("\n")), this.logs = this.logs.concat(t)
|
||||
}
|
||||
}
|
||||
|
||||
log(...t){
|
||||
log(...t) {
|
||||
t.length > 0 && (this.logs = [...this.logs, ...t]), console.log(t.join(this.logSeparator))
|
||||
}
|
||||
|
||||
logErr(t, e){
|
||||
logErr(t, e) {
|
||||
const s = !this.isSurge() && !this.isQuanX() && !this.isLoon();
|
||||
s ? this.log("", `❗️${this.name}, 错误!`, t.stack) : this.log("", `❗️${this.name}, 错误!`, t)
|
||||
}
|
||||
|
||||
wait(t){
|
||||
wait(t) {
|
||||
return new Promise(e => setTimeout(e, t))
|
||||
}
|
||||
|
||||
done(t = {}){
|
||||
done(t = {}) {
|
||||
const e = (new Date).getTime(),
|
||||
s = (e - this.startTime) / 1e3;
|
||||
this.log("", `🔔${this.name}, 结束! 🕛 ${s} 秒`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t)
|
||||
|
|
|
@ -43,30 +43,6 @@ let allMessage = '';
|
|||
$.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"});
|
||||
return;
|
||||
}
|
||||
let res = await getAuthorShareCode('')
|
||||
for (let i = 0; i < cookiesArr.length; i++) {
|
||||
if (cookiesArr[i]) {
|
||||
cookie = cookiesArr[i];
|
||||
$.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1])
|
||||
$.index = i + 1;
|
||||
$.isLogin = true;
|
||||
$.nickName = '';
|
||||
message = '';
|
||||
await TotalBean();
|
||||
isLoginInfo[$.UserName] = $.isLogin
|
||||
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"});
|
||||
|
||||
if ($.isNode()) {
|
||||
await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`);
|
||||
}
|
||||
continue
|
||||
}
|
||||
await jdConnoisseur()
|
||||
}
|
||||
}
|
||||
$.shareCodes = [...new Set([...$.shareCodes, ...(res || [])])]
|
||||
for (let i = 0; i < cookiesArr.length; i++) {
|
||||
if (cookiesArr[i]) {
|
||||
cookie = cookiesArr[i];
|
||||
|
@ -389,12 +365,10 @@ function interactive_done(type, projectId, assignmentId, itemId, actionType = ''
|
|||
}
|
||||
async function sign_interactive_done(type, projectId, assignmentId) {
|
||||
let functionId = 'interactive_done'
|
||||
let body = JSON.stringify({"assignmentId":assignmentId,"type":type,"projectId":projectId})
|
||||
let uuid = randomString(40)
|
||||
let sign = await getSign(functionId, body, uuid)
|
||||
let url = `${JD_API_HOST}client.action?functionId=${functionId}&client=apple&clientVersion=10.1.0&uuid=${uuid}&${sign}`
|
||||
let body = {"assignmentId":assignmentId,"type":type,"projectId":projectId}
|
||||
let sign = await getSign(functionId, body)
|
||||
return new Promise(resolve => {
|
||||
$.post(taskPostUrl(url, body), (err, resp, data) => {
|
||||
$.post(taskPostUrl(functionId, sign), (err, resp, data) => {
|
||||
try {
|
||||
if (err) {
|
||||
console.log(`${JSON.stringify(err)}`)
|
||||
|
@ -459,12 +433,10 @@ function interactive_accept(type, projectId, assignmentId, itemId) {
|
|||
}
|
||||
async function qryViewkitCallbackResult(encryptProjectId, encryptAssignmentId, itemId) {
|
||||
let functionId = 'qryViewkitCallbackResult'
|
||||
let body = JSON.stringify({"dataSource":"babelInteractive","method":"customDoInteractiveAssignmentForBabel","reqParams":`{\"itemId\":\"${itemId}\",\"encryptProjectId\":\"${encryptProjectId}\",\"encryptAssignmentId\":\"${encryptAssignmentId}\"}`})
|
||||
let uuid = randomString(40)
|
||||
let sign = await getSign(functionId, body, uuid)
|
||||
let url = `${JD_API_HOST}client.action?functionId=${functionId}&client=apple&clientVersion=10.1.0&uuid=${uuid}&${sign}`
|
||||
let body = {"dataSource":"babelInteractive","method":"customDoInteractiveAssignmentForBabel","reqParams":`{\"itemId\":\"${itemId}\",\"encryptProjectId\":\"${encryptProjectId}\",\"encryptAssignmentId\":\"${encryptAssignmentId}\"}`}
|
||||
let sign = await getSign(functionId, body)
|
||||
return new Promise(resolve => {
|
||||
$.post(taskPostUrl(url, body), (err, resp, data) => {
|
||||
$.post(taskPostUrl(functionId, sign), (err, resp, data) => {
|
||||
try {
|
||||
if (err) {
|
||||
console.log(`${JSON.stringify(err)}`)
|
||||
|
@ -593,10 +565,10 @@ function taskUrl(functionId, body) {
|
|||
}
|
||||
}
|
||||
}
|
||||
function taskPostUrl(url, body) {
|
||||
function taskPostUrl(functionId, body) {
|
||||
return {
|
||||
url,
|
||||
body: `body=${encodeURIComponent(body)}`,
|
||||
url: `${JD_API_HOST}client.action?functionId=${functionId}`,
|
||||
body,
|
||||
headers: {
|
||||
"Host": "api.m.jd.com",
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
|
@ -611,14 +583,13 @@ function taskPostUrl(url, body) {
|
|||
}
|
||||
}
|
||||
}
|
||||
function getSign(functionid, body, uuid) {
|
||||
function getSign(functionId, body) {
|
||||
return new Promise(async resolve => {
|
||||
let data = {
|
||||
"functionId":functionid,
|
||||
"body":body,
|
||||
"uuid":uuid,
|
||||
functionId,
|
||||
body: JSON.stringify(body),
|
||||
"client":"apple",
|
||||
"clientVersion":"10.1.0"
|
||||
"clientVersion":"10.3.0"
|
||||
}
|
||||
let HostArr = ['jdsign.cf', 'signer.nz.lu']
|
||||
let Host = HostArr[Math.floor((Math.random() * HostArr.length))]
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,9 +1,3 @@
|
|||
/*
|
||||
* @Author: LXK9301 https://github.com/LXK9301
|
||||
* @Date: 2021-8-20
|
||||
* @Last Modified by: LXK9301
|
||||
* @Last Modified time: 2020-12-26 22:58:02
|
||||
*/
|
||||
/*
|
||||
东东工厂,不是京喜工厂
|
||||
活动入口:京东APP首页-数码电器-东东工厂
|
||||
|
@ -18,17 +12,17 @@
|
|||
============Quantumultx===============
|
||||
[task_local]
|
||||
#东东工厂
|
||||
10 0,6-23 * * * https://gitee.com/lxk0301/jd_scripts/raw/master/jd_jdfactory.js, tag=东东工厂, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_factory.png, enabled=true
|
||||
10 0,6-23 * * * https://raw.githubusercontent.com/KingRan/JDJB/main/jd_jdfactory.js, tag=东东工厂, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_factory.png, enabled=true
|
||||
|
||||
================Loon==============
|
||||
[Script]
|
||||
cron "10 0,6-23 * * *" script-path=https://gitee.com/lxk0301/jd_scripts/raw/master/jd_jdfactory.js,tag=东东工厂
|
||||
cron "10 0,6-23 * * *" script-path=https://raw.githubusercontent.com/KingRan/JDJB/main/jd_jdfactory.js,tag=东东工厂
|
||||
|
||||
===============Surge=================
|
||||
东东工厂 = type=cron,cronexp="10 0,6-23 * * *",wake-system=1,timeout=3600,script-path=https://gitee.com/lxk0301/jd_scripts/raw/master/jd_jdfactory.js
|
||||
东东工厂 = type=cron,cronexp="10 0,6-23 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/KingRan/JDJB/main/jd_jdfactory.js
|
||||
|
||||
============小火箭=========
|
||||
东东工厂 = type=cron,script-path=https://gitee.com/lxk0301/jd_scripts/raw/master/jd_jdfactory.js, cronexpr="10 0,6-23 * * *", timeout=3600, enable=true
|
||||
东东工厂 = type=cron,script-path=https://raw.githubusercontent.com/KingRan/JDJB/main/jd_jdfactory.js, cronexpr="10 0,6-23 * * *", timeout=3600, enable=true
|
||||
*/
|
||||
const $ = new Env('东东工厂');
|
||||
|
||||
|
@ -53,7 +47,6 @@ const JD_API_HOST = 'https://api.m.jd.com/client.action';
|
|||
const inviteCodes = [];
|
||||
let myInviteCode;
|
||||
$.newShareCode = [];
|
||||
let llhelp=true;
|
||||
!(async () => {
|
||||
if (!cookiesArr[0]) {
|
||||
$.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', { "open-url": "https://bean.m.jd.com/bean/signIndex.action" });
|
||||
|
@ -81,19 +74,6 @@ let llhelp=true;
|
|||
await jdFactory()
|
||||
}
|
||||
}
|
||||
if(llhelp){
|
||||
console.log(`\n开始账号内互助......`);
|
||||
for (let j = 0; j < cookiesArr.length; j++) {
|
||||
if (cookiesArr[j]) {
|
||||
cookie = cookiesArr[j];
|
||||
$.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1])
|
||||
$.nickName = '';
|
||||
$.index = j + 1;
|
||||
console.log(`【京东账号${$.index}】${$.nickName || $.UserName}:\n`);
|
||||
await helpFriends();
|
||||
}
|
||||
}
|
||||
}
|
||||
})()
|
||||
.catch((e) => {
|
||||
$.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '')
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue