mirror of
https://github.com/shufflewzc/faker3.git
synced 2024-11-14 07:29:18 +08:00
151 lines
34 KiB
JavaScript
151 lines
34 KiB
JavaScript
|
/*
|
|||
|
关注有礼-自动解析通用
|
|||
|
环境变量 样例
|
|||
|
export whx_drawShopGift="https://u.jd.com/VtcZjCp"
|
|||
|
7 7 7 7 7 jd_whx_drawShopGift.js
|
|||
|
*/
|
|||
|
const $ = new Env('关注有礼-自动解析通用');
|
|||
|
const notify = $.isNode() ? require('./sendNotify') : '';
|
|||
|
const axios = require("axios")
|
|||
|
const jdCookieNode = $.isNode() ? require('./jdCookie.js') : '';
|
|||
|
let cookiesArr = [], cookie = '';
|
|||
|
let jfurl = process.env.whx_drawShopGift ?? "https://u.jd.com/VIHwZ33";
|
|||
|
|
|||
|
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);
|
|||
|
}
|
|||
|
!(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" });
|
|||
|
return;
|
|||
|
}
|
|||
|
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();
|
|||
|
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
|
|||
|
}
|
|||
|
$.jfurl = jfurl
|
|||
|
$.hrl = ''
|
|||
|
$.shopId = ''
|
|||
|
$.gx = ''
|
|||
|
$.utm_campaign = ''
|
|||
|
$.utm_term = ''
|
|||
|
$.activityId = ''
|
|||
|
await main()
|
|||
|
await $.wait(2000);
|
|||
|
}
|
|||
|
}
|
|||
|
})().catch((e) => { $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') }).finally(() => { $.done(); })
|
|||
|
|
|||
|
async function main(){
|
|||
|
await getShorttoLong()
|
|||
|
await whx_getShopHomeActivityInfo()
|
|||
|
if ($.activityId) {
|
|||
|
await whx_drawShopGift()
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
async function getShort(short) {
|
|||
|
try {
|
|||
|
let { data } = await axios.get(short);
|
|||
|
if (data) {
|
|||
|
let jump = data.match(/hrl=\'(.*)\';var.ua/)[1];
|
|||
|
if (jump) {
|
|||
|
return await axios
|
|||
|
.get(jump)
|
|||
|
.then((res) => {
|
|||
|
return res.request?._redirectable?._currentUrl;
|
|||
|
})
|
|||
|
.catch((err) => {
|
|||
|
return err.request?._redirectable?._currentUrl;
|
|||
|
});
|
|||
|
} else {
|
|||
|
return null;
|
|||
|
}
|
|||
|
} else {
|
|||
|
return null;
|
|||
|
}
|
|||
|
} catch (error) {
|
|||
|
return null;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
async function getShorttoLong() {
|
|||
|
return getShort($.jfurl).then(long=>{
|
|||
|
console.log(long);
|
|||
|
$.hrl = long
|
|||
|
})
|
|||
|
}
|
|||
|
|
|||
|
var _0xodk='jsjiami.com.v6',_0xodk_=['_0xodk'],_0x3c82=[_0xodk,'QWrDiQ==','eQwWJXI=','wrnCsMO/Fwk=','w6rDgsKN','NsOlw6d3','fMOMwpzCrsOc','wrBUCFjCi8KQ','bMKNcjbCqcOBawZDPUPCnQ==','wo/DoMOJw6HDhg==','w6ZPwpbDnMKH','w6RxIyZEQcOTw7o=','bcK4eEQXwpA=','FXR5','wozCoBQfFsO2wqBR','EELDs1hH','Fy3DosK8Iic=','dcKcaQzCpsO6YwRNGUHCnXHCjig3','X8KFw7AdVw==','fsKhw68hSA==','wpVqwq5XC8Okw4gBFw==','AMOxLMOOw4XCkWwo','fsOHF8Ouw5kt','P2UpwqV6VMOKUMO+OQ==','wqPClC0yBw==','P2UpwqV6VMOKUMO+OcKu','w5hVwo/Cr1PCk8K9ZcK3wpc=','w5HDrcKfJMOi','wqnDuMOWw6B3','UMKDVzHCsw==','MHvDl0tQ','GMOoTgFNDw==','BsOoSxFNIXPDvMOqasOwwp0FMsKXw5M=','fsKQeR3CiMOBYTJDIEXCoWHCqC83wro=','woQUwp91wovDjQ==','bMOwfUkUwrrDgSsneXPCvwxqZBY=','w5t1I8OBZnpXFcKx','wr/CthMBAw==','wqjCiSwWAg==','wpvCpg4SBcOtwp1MEcKt','fG7CoCTDmA4=','w4p5K8ORQWl5NcOtMVXCmXtFwqPCrQA=','TcOpwqzCtsO7P8K+wpfCrMOS','BsOiWg==','5LiV5Lqc5p2b5Yqh5Ziz6L6D5ZmY56qA5peJ5o2B','w5LClsOKw7XCtMKP','NsOnNcOmVMO+BcKGwqJBKcOHesKLw4TCq2I=','w4UnK8KYw4o=','wq7DisOHw53DhQ==','JB95w4vCmicrFA==','W8OwwqxCw4DDhTLCghPCiA==','wq3CqcO1Cj8ww7UtEsKWO8OtwqB8NsK4Sg==','w5VZwpw=','HMO4NcO/w5E=','NghbZsO0wqvCrFV5PFg=','eQQSIEdzK33CtgA=','CjlhFhA=','M8OWNQ==','wpvDosK/w4hqw5PCpXnCg8Ofw7I1AcOCw4/CoQRlCQ==','w7AIMsK8w5Eq','wrg/wrR3wrI=','w7kBDcKhw7Y=','NnIpwrx/B8KRBsOWLcOnPn4tw4fDhcKVTcKLM3fCsG9mSMKQw5FCcHwVdcOSXsKdfAXDlR9vEsKFwofDoMOdOMODJcKhwrDDm8KFw6rDriHCjMOOw5fDtToPwpjCicOzacOkwqp4','w7LDkDhlNg==','IsO6IcO7eMO4C8Kkwro=','csOVw7cz','wpTCqg0=','w5rDp8Ohw4DDnSHDjsKyYXMqw5RDbXdyeiLDtcKBRioAdVPDvsK8wrTDtmx7w6UVdMOFwpBgJW5Uw6t+wrTDtcKbwqTCoUbDnxPDvSNEw7A0w57DkycMw7c=','w5fDocKHNcOA','w5jCksOcw4nDpgPCqMO1BkfDgcKqwqdmw6YMMcKOQyBs','fx0POR06O2HCmQhZw753RcKZQMKI','L1xWHEY=','UyQhGWY=','VcKMw4c9WQ==','dAgB','eQsULFB+JlbCmgddw6NkDMOdZcKTwovCsEw=','QQV1wpsKG0fCog==','wonDvHg0w69u','fG7CtwbDmwha','wpFqwrNGAsOi','w6IML8Kpw7kqw4g9TWfCr1HDqsO/bko2w6UVw4g=','w5LClsOYw7LCj8KUVMO1','wq4BGwjCqQ==','wpdIFXLCsw==','w5/CjsO8w47DlA==','wo9gwqc=','5LiV5Liq5p+25Ymn5ZmN6Lyu5ZiX56mm5paO5o6d','dcKWeCzCuMOS','wpbCqh0=','J8O+w7Fnf8O5dsOgwqY=','w4lmwp3DjsKMIkTClk4=','GcOmHcOjWQ==','HMOMfh5N','w7pxOcOQQg==','esOpUDsM','w4AcCU1GwoBjw5V1','w7NxGTha','bMKNcjbCqcOBawZDPUPCnTk=','O8O9Ux0rT8KRw4bCkcO3','w4XCksOFw6bDoVzDtcK3SA==','wrdOEk0=','w43DhcKZN8ORwooW','Z8ONCsO8','woHDsSYCw402wpxyworCpCMjw4fDlxkTw41twqQ=','w5zCsA4WLMOxwppQKsO0','ScO7wrdbw7/DiHs=','woUZwo1ywoI=','SsO/wq1Yw5vDiSvCmT/Cng==','wotzOMKY','QC8Lw54fw6FgasK0w4I+','w6nCgMKJw53DqcOG','w5jClMOE','w4pewpTCtmzCnsO0','cGLDh8OPwrs=','w4xrwpzDmsKgNA==','OyhvFwk=','PxlD','w6BMwpnCq3Q=','w7nCosOuw4nCrA==','IsOmPMOiX8O7Qg==','ZcO+wpfCqcOP','ZcOzw78=','DmN4F0U=','Ih9CUMOhwqPCtVxRMR/Drw==','G18FwoZ0','w4vDtMKwwozDrQ==','cE3DvcOgwps=','wpTDvsO/w5RQwprCrXw=','w5FEwpc=','LXYxwqV4','YsONEw==','Ezxaw5s=','wpPCsjMVAw==','w4TClMOdw5w=','J8Oiw6x+WMO6','bRMLFlJ7MnTCng1fw6Q=','w4XDv8OWJHArwrDDrg==','wp/Ds0EXw6k=','MysuwqRjTQ==','w5dxwp8=','w7QqNcKEw54=','w45mwqHCrk4=','wpTDoMOjw6jDnA==','QsOlwq8=','wpgewps=','f8OKwoBhw44=','w5jDucOX','wpLDosO9w7ttwpvDog==','wpFyDhjCuA==','H3rDmH5KDsKTaHrDlMKXwpw=','OiJiaMOv','wrZTN0fCrg==','B1MFwo59','wpvCnBAiJQ==','w7fDhcKVw4XDj8OS','JMO6PsONdcO+D8KywqJcL8O7','QsO6wopSw5k=','M8OjB8OXZA==','Ih9CUMO2wqfCqkE=','XsO5wpJ9w5w=','EBtfw5rCng==','H3rDmH5dCsKMdSY=','wq9TAA==','HjN5w7XCvA==','X25qPE8UwpDClgbCoQ==','WcOEXGUM','w5QGwps=','VcO3PMOZw4Q=','wrBUBlrCpw==','w5jDmTxZDQ==','ecKZw6kBXA==','woMWQm3DsEzDqcOPCWxLw4PChA1Cwr3CmGnDiMOOKnDDpkNGwp/CnMK/w6HDuhUCesKldMKbwpDCom4UHMOSwrJgw5M8wo3CrixGNhHCh0zCicK1w6nDh8O+wqpebigpecK1HR3DrjN3woHCsApgwpIhw6FV','w4PDv8OJEmopwqvDpcK+','ecKbw5k9','w50jEgDChcKRCcK3wrIKwpxJHMKPTcKJw7hHacKZwpbDjX8fBsKkw5TCjMOPdzhIwoJ0w6law5jDgcKVcsKZw77CjcOYUFh4w6gDwqVlw7sBRcK7wqcAw7U6wqY=','w5vDgsO/','PMO+w7d+YsKkMMKpwqzClw7DqsOKwpx5RSbCnsOZUQA=','M8Oww6p+PcK+e8OjwrnCkwDDrsKBw513TTA=','RMOMW2gL','J8OiRx1NF3fCocKwCcKlw5NYDsK1w5dNw7LCgsODVWHDiMO+w73CucKKCsKxw5LDtH/Cp09HcQLDv8K5G8OFw4jChx3DjVxew6bDpW7CrsOPfgAFOsOQw5nCvhnDqyNJw7FbwpPDlMOWwplRwozDrMKhwrXDp8KPw5HCnsOLQMK7A8K3w5Qme8OxAE7Dh8OuMmfDoBfCiB1fwoDDhULDugnDgsKGDsKpw404fQtbQwDDlMOGHUnDkGwkGXbDjxnCuMORFcK5dmfDrkLChcO6wojDkcKHw7I=',
|
|||
|
// prettier-ignore
|
|||
|
function getSubstr(str, leftStr, rightStr){
|
|||
|
let left = str.indexOf(leftStr);
|
|||
|
let right = str.indexOf(rightStr, left);
|
|||
|
if(left < 0 || right < left) return '';
|
|||
|
return str.substring(left + leftStr.length, right);
|
|||
|
}
|
|||
|
function TotalBean() {
|
|||
|
return new Promise(async resolve => {
|
|||
|
const options = {
|
|||
|
"url": `https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2`,
|
|||
|
"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",
|
|||
|
"Cookie": cookie,
|
|||
|
"Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2",
|
|||
|
"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.2 Mobile/15E148 Safari/604.1"
|
|||
|
}
|
|||
|
}
|
|||
|
$.post(options, (err, resp, data) => {
|
|||
|
try {
|
|||
|
if (err) {
|
|||
|
console.log(`${JSON.stringify(err)}`)
|
|||
|
console.log(`${$.name} API请求失败,请检查网路重试`)
|
|||
|
} else {
|
|||
|
if (data) {
|
|||
|
data = JSON.parse(data);
|
|||
|
if (data['retcode'] === 13) {
|
|||
|
$.isLogin = false; //cookie过期
|
|||
|
return
|
|||
|
}
|
|||
|
if (data['retcode'] === 0) {
|
|||
|
$.nickName = (data['base'] && data['base'].nickname) || $.UserName;
|
|||
|
} else {
|
|||
|
$.nickName = $.UserName
|
|||
|
}
|
|||
|
} else {
|
|||
|
console.log(`京东服务器返回空数据`)
|
|||
|
}
|
|||
|
}
|
|||
|
} catch (e) {
|
|||
|
$.logErr(e, resp)
|
|||
|
} finally {
|
|||
|
resolve();
|
|||
|
}
|
|||
|
})
|
|||
|
})
|
|||
|
}
|
|||
|
function Env(t, e) { "undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0); class s { constructor(t) { this.env = t } send(t, e = "GET") { t = "string" == typeof t ? { url: t } : t; let s = this.get; return "POST" === e && (s = this.post), new Promise((e, i) => { s.call(this, t, (t, s, r) => { t ? i(t) : e(s) }) }) } get(t) { return this.send.call(this.env, t) } post(t) { return this.send.call(this.env, t, "POST") } } 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() { return "undefined" != typeof module && !!module.exports } isQuanX() { return "undefined" != typeof $task } isSurge() { return "undefined" != typeof $httpClient && "undefined" == typeof $loon } isLoon() { return "undefined" != typeof $loon } toObj(t, e = null) { try { return JSON.parse(t) } catch { return e } } toStr(t, e = null) { try { return JSON.stringify(t) } catch { return e } } getjson(t, e) { let s = e; const i = this.getdata(t); if (i) try { s = JSON.parse(this.getdata(t)) } catch { } return s } setjson(t, e) { try { return this.setdata(JSON.stringify(t), e) } catch { return !1 } } getScript(t) { return new Promise(e => { this.get({ url: t }, (t, s, i) => e(i)) }) } runScript(t, e) { return new Promise(s => { let i = this.getdata("@chavy_boxjs_userCfgs.httpapi"); i = i ? i.replace(/\n/g, "").trim() : i; let r = this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout"); r = r ? 1 * r : 20, r = e && e.timeout ? e.timeout : r; const [o, h] = i.split("@"), n = { url: `http://${h}/v1/scripting/evaluate`, body: { script_text: t, mock_type: "cron", timeout: r }, headers: { "X-Key": o, Accept: "*/*" } }; this.post(n, (t, e, i) => s(i)) }).catch(t => this.logErr(t)) } 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 {}; { const i = s ? t : e; try { return JSON.parse(this.fs.readFileSync(i)) } catch (t) { return {} } } } } 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), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e), r = JSON.stringify(this.data); s ? this.fs.writeFileSync(t, r) : i ? this.fs.writeFileSync(e, r) : this.fs.writeFileSync(t, r) } } 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; return r } 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) { let e = this.getval(t); if (/^@/.test(t)) { const [, s, i] = /^@(.*?)\.(.*?)$/.exec(t), r = s ? this.getval(s) : ""; if (r) try { const t = JSON.parse(r); e = t ? this.lodash_get(t, i, "") : e } catch (t) { e = "" } } return e } setdata(t, e) { let s = !1; if (/^@/.test(e)) { const [, i, r] = /^@(.*?)\.(.*?)$/.exec(e), o = this.getval(i), h = i ? "null" === o ? null : o || "{}" : "{}"; try { const e = JSON.parse(h); this.lodash_set(e, r, t), s = this.setval(JSON.stringify(e), i) } catch (e) { const o = {}; this.lodash_set(o, r, t), s = this.setval(JSON.stringify(o), i) } } else s = this.setval(t, e); return s } 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.d
|