diff --git a/jd_10_4.js b/jd_10_4.js new file mode 100644 index 0000000..fdb6f5c --- /dev/null +++ b/jd_10_4.js @@ -0,0 +1,178 @@ +/* +极速版抢卷 + +============Quantumultx=============== +[task_local] +#极速版抢卷 +58 59 7,10,13,15,19 * * * https://raw.githubusercontent.com/shufflewzc/faker2/main/jd_10_4.js, tag=极速版抢卷, enabled=true +================Loon============== +[Script] +cron "58 59 7,10,13,15,19 * * *" script-path=https://raw.githubusercontent.com/shufflewzc/faker2/main/jd_10_4.js,tag=极速版抢卷 +===============Surge================= +极速版抢卷 = type=cron,cronexp="58 59 7,10,13,15,19 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/shufflewzc/faker2/main/jd_10_4.js +============小火箭========= +极速版抢卷 = type=cron,script-path=https://raw.githubusercontent.com/shufflewzc/faker2/main/jd_10_4.js, cronexpr="58 59 7,10,13,15,19 * * *", timeout=3600, enable=true + */ +const $ = new Env('抢极速版全品卷10-4'); +const moment = require('moment'); +//进容器安装依赖: pnpm install -g moment +const notify = $.isNode() ? require('./sendNotify') : ''; +//Node.js用户请在jdCookie.js处填写京东ck; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +let jdNotify = true;//是否关闭通知,false打开通知推送,true关闭通知推送 +const randomCount = $.isNode() ? 30 : 5; +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], cookie = '', message; +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); +} +const JD_API_HOST = 'https://api.m.jd.com/client.action?'; +let wait = ms => new Promise(resolve => setTimeout(resolve, ms)); +!(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; + } + await wait(100) + for (let j = 0; j < randomCount; ++j) + for (let i = 0; i < 7; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + console.log(`*********京东账号${$.index} ${$.UserName}*********`) + $.isLogin = true; + $.nickName = ''; + message = ''; + await qiang(); + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + +async function qiang() { + await exchange() +} + +function exchange() { + return new Promise(resolve => { + $.post(taskUrl('functionId=lite_newBabelAwardCollection'), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} user/exchange/bean API请求失败,请检查网路重试\n`) + } else { + console.log(moment().format("YYYY-MM-DD HH:mm:ss.SSS")); + console.log(data); + if (safeGet(data)) { + data = JSON.parse(data); + console.log(`抢券结果:${JSON.stringify(data)}\n`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function taskUrl(function_id, body = {}) { + return { + url: `https://api.m.jd.com/client.action?functionId=lite_newBabelAwardCollection`, + headers: { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + 'origin': 'https://pro.m.jd.com', + "Referer": "https://pro.m.jd.com/jdlite/active/3H885vA4sQj6ctYzzPVix4iiYN2P/index.html?lng=106.476617&lat=29.502674&sid=fbc43764317f538b90e0f9ab43c8285w&un_area=4_50952_106_0", + "Cookie": cookie, + "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"), + }, + body: "body=%7B%22activityId%22%3A%22vN4YuYXS1mPse7yeVPRq4TNvCMR%22%2C%22scene%22%3A%221%22%2C%22args%22%3A%22key%3D440A3074D8054F656466EE989DEF40E4DE6342B45A4AB5D48889C7B31DD4E52ED6EB7F5C0174376325C72F3C5D85C6AA_bingo%2CroleId%3DB1781EF2C2537FB0E4A5B23AC99529A4_bingo%2CstrengthenKey%3D7234093DC9375F51DDB7D38147D7AD82EAEB0938B43AC37CCC32084DCB1D132294C36DD5B5FB28701E8CAE4B19940E53_bingo%22%2C%22platform%22%3A%221%22%2C%22orgType%22%3A%222%22%2C%22openId%22%3A%22-1%22%2C%22pageClickKey%22%3A%22-1%22%2C%22eid%22%3A%22EI7EMAW4ZLYP7BA2NPR3ZRDMA62D4SQSQ4OOFANS47F4GEBK2DN3LPSAVISERLPHUS75YZCZUXNDFNIQKRL6PXLHCE%22%2C%22fp%22%3A%22a3471ae389dc8ceb177c46af7f2be393%22%2C%22shshshfp%22%3A%2232baea6b7239fd61f7c031e2b9a64872%22%2C%22shshshfpa%22%3A%22f62b6f85-ed1a-19a9-a983-5386fd853f3e-1633620784%22%2C%22shshshfpb%22%3A%22ahOTWEXBkXAwoXwuc7Jo5WQ%22%2C%22childActivityUrl%22%3A%22https%253A%252F%252Fpro.m.jd.com%252Fjdlite%252Factive%252FvN4YuYXS1mPse7yeVPRq4TNvCMR%252Findex.html%253Flng%253D106.476355%2526lat%253D29.502681%2526sid%253Dc0bd62a7a67b30b66ea8792ba0d6709w%2526un_area%253D4_50952_106_0%22%2C%22userArea%22%3A%22-1%22%2C%22client%22%3A%22-1%22%2C%22clientVersion%22%3A%22-1%22%2C%22uuid%22%3A%22-1%22%2C%22osVersion%22%3A%22-1%22%2C%22brand%22%3A%22-1%22%2C%22model%22%3A%22-1%22%2C%22networkType%22%3A%22-1%22%2C%22jda%22%3A%22122270672.16425253116601960425755.1642525311.1649470106.1649491188.363%22%2C%22sdkToken%22%3A%22%22%2C%22token%22%3A%22P6TCVEBDDQSIU4TFMLEIGCRZM725EZ2UT2FTFXUREWF6FVWYTQM7NBQDYC5LL3PB2JAW4ICLAEBQQ%22%2C%22jstub%22%3A%22QGBEPCICYTPIW4W3IDOUU3EDSVAXGKPA6I76AXWGBLWQY7GKRG2GGKAYWA5EYKWDVKZYKB6HMUKJZISPBAMSK6EIDXOULB7F2CCQVHI%22%2C%22pageClick%22%3A%22Babel_Coupon%22%2C%22couponSource%22%3A%22ace%22%2C%22couponSourceDetail%22%3A%22-100%22%2C%22channel%22%3A%22%E9%80%9A%E5%A4%A9%E5%A1%94%E4%BC%9A%E5%9C%BA%22%2C%22batchId%22%3A%22850335346%22%2C%22headArea%22%3A%22605715ec560d6508f7403b91b677d79c%22%2C%22mitemAddrId%22%3A%22%22%2C%22geo%22%3A%7B%22lng%22%3A%22106.476355%22%2C%22lat%22%3A%2229.502681%22%7D%2C%22addressId%22%3A%22%22%2C%22posLng%22%3A%22%22%2C%22posLat%22%3A%22%22%2C%22focus%22%3A%22%22%2C%22innerAnchor%22%3A%22%22%2C%22cv%22%3A%222.0%22%2C%22log%22%3A%221649491226114~1PorQLSs0EBMDFxR29wZDk5MQ%3D%3D.QHFbSVBIdl1CV0d0WQ5WO3A9IlxDcAxAGkBrWVxVXXYRQhpAOQ4YKyUQKigmGh8uBwspMBoTUzsoWic1Dw%3D%3D.301c2d99~1%2C1~D80C455A87315B78D0BEF84CB0C0BF40AD78C5EC~0f8th9w~C~TRtNXxQLbWQVEEJfWxsDaRRVAxQKfRpyeBULfXUdVxVNEBoTUg4UAXkddXcVAGZwGlgVRhRsGhteQFgTDAgVEEVCFAMbAwAFDw0AAwQDBA0KBQcIBQwbHhRGU10bCBRFQk1NRlBEUBsVEEFUVxsDEFBXQk1NRkNQFBUbQlJfFANiAA4dAAgBHgcHGg4VAxoEaxUbWFwTDAgVEFVCFAMbBFUEUA4PVAQGBF8PAFJTVFpcBw9QD10LBlIEBV8LUwcTGhtXQhQLFFBpWllfUxsVEEITDAgPBg8FDwgLAAAABw0VEFxaFAMbUxQdFF9JUBQLFFhRfWJmc2F7WW5wQVZhRUNSAXNWB2FgFBUbXEATDBt4QkZdUxl6XVtBQ01cQBoRf1daHBQdFFdYRBQLFAgIAAUTGhtKUUQTDGIOAQAdAggNbxoTRFYbCG0TX2lRXVhUDhULEBoTX3ZqEBoTBw0XChQdFAoXChgABhsVEAcABAobHhRQVABfVA8JBwkNUVcAUglcCwAHBV9cAwRTAQkMUVcBAglYVAQDAFxaEBoTVxtkHhRYWVgbCBRXUF9fVFBFQhsVEFdbFAMbRxQdFFpQEAwTQQoXBxgDFBUbUVBuQBsDEA8IFBUbUFITDBtLU1hVWVQEYk9SDnVUQncTGhtUWBQLbQgVAhoBaxUbUFpeURsDEFcTGhtUQVETDBtYEEs%3D~1uryqfc%22%2C%22random%22%3A%22Pyc8LmpA%22%2C%22floor_id%22%3A%2275821126%22%7D&screen=1242*2016&client=wh5&clientVersion=1.0.0&sid=c0bd62a7a67b30b66ea8792ba0d6709w&uuid=16425253116601960425755.106.1649491225405&area=4_50952_106_0" + } +} + +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": $.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") + } + } + $.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 safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} +// prettier-ignore +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.data[t] || null } 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) { 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 = (() => { })) { 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) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) })) : this.isQuanX() ? (this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t))) : this.isNode() && (this.initGotEnv(t), this.got(t).on("redirect", (t, e) => { 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) { this.logErr(t) } }).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) })) } 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, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t)); else if (this.isNode()) { this.initGotEnv(t); const { url: s, ...i } = t; this.got.post(s, i).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) }) } } time(t, e = null) { const s = e ? new Date(e) : new Date; let i = { "M+": s.getMonth() + 1, "d+": s.getDate(), "H+": s.getHours(), "m+": s.getMinutes(), "s+": s.getSeconds(), "q+": Math.floor((s.getMonth() + 3) / 3), 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))); return t } msg(e = t, s = "", i = "", r) { const o = t => { 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()) { let e = t.openUrl || t.url || t["open-url"], s = t.mediaUrl || t["media-url"]; return { openUrl: e, mediaUrl: s } } if (this.isQuanX()) { let e = t["open-url"] || t.url || t.openUrl, s = t["media-url"] || t.mediaUrl; return { "open-url": e, "media-url": s } } if (this.isSurge()) { let e = t.url || t.openUrl || t["open-url"]; return { url: 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) { 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) { t.length > 0 && (this.logs = [...this.logs, ...t]), console.log(t.join(this.logSeparator)) } 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) { return new Promise(e => setTimeout(e, 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) } }(t, e) } diff --git a/jd_carnivalcity_help.js b/jd_carnivalcity_help.js index b09e41d..9c3250a 100644 --- a/jd_carnivalcity_help.js +++ b/jd_carnivalcity_help.js @@ -7,17 +7,17 @@ ===================quantumultx================ [task_local] #京东手机狂欢城助力 -10 0,8 * * * https://raw.githubusercontent.com/KingRan/KR/main/jd_carnivalcity_help.js, tag=京东手机狂欢城助力, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true +10 0,8 * * * https://raw.githubusercontent.com/shufflewzc/faker2/main/jd_carnivalcity_help.js, tag=京东手机狂欢城助力, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true =====================Loon================ [Script] -cron "10 0,8 * * *" script-path=https://raw.githubusercontent.com/KingRan/KR/main/jd_carnivalcity_help.js, tag=京东手机狂欢城助力 +cron "10 0,8 * * *" script-path=https://raw.githubusercontent.com/shufflewzc/faker2/main/jd_carnivalcity_help.js, tag=京东手机狂欢城助力 ====================Surge================ -京东手机狂欢城助力 = type=cron,cronexp=10 0,8 * * *,wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/KingRan/KR/main/jd_carnivalcity_help.js +京东手机狂欢城助力 = type=cron,cronexp=10 0,8 * * *,wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/shufflewzc/faker2/main/jd_carnivalcity_help.js ============小火箭========= -京东手机狂欢城助力 = type=cron,script-path=https://raw.githubusercontent.com/KingRan/KR/main/jd_carnivalcity_help.js, cronexpr="10 0,8 * * *", timeout=3600, enable=true +京东手机狂欢城助力 = type=cron,script-path=https://raw.githubusercontent.com/shufflewzc/faker2/main/jd_carnivalcity_help.js, cronexpr="10 0,8 * * *", timeout=3600, enable=true */ const $ = new Env('京东手机狂欢城内部互助'); const notify = $.isNode() ? require('./sendNotify') : ''; diff --git a/jd_dpqd.js b/jd_dpqd.js index fd3dabd..a45f5c0 100644 --- a/jd_dpqd.js +++ b/jd_dpqd.js @@ -3,14 +3,14 @@ ============Quantumultx=============== [task_local] #店铺签到 -15 2,14 * * * https://raw.githubusercontent.com/KingRan/KR/main/jd_shop_sign.js, tag=店铺签到, enabled=true +15 2,14 * * * https://raw.githubusercontent.com/shufflewzc/faker2/main/jd_shop_sign.js, tag=店铺签到, enabled=true ===========Loon============ [Script] -cron "15 2,14 * * *" script-path=https://raw.githubusercontent.com/KingRan/KR/main/jd_shop_sign.js,tag=店铺签到 +cron "15 2,14 * * *" script-path=https://raw.githubusercontent.com/shufflewzc/faker2/main/jd_shop_sign.js,tag=店铺签到 ============Surge============= -店铺签到 = type=cron,cronexp="15 2,14 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/KingRan/KR/main/jd_shop_sign.js +店铺签到 = type=cron,cronexp="15 2,14 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/shufflewzc/faker2/main/jd_shop_sign.js ===========小火箭======== -店铺签到 = type=cron,script-path=https://raw.githubusercontent.com/KingRan/KR/main/jd_shop_sign.jss, cronexpr="15 2,14 * * *", timeout=3600, enable=true +店铺签到 = type=cron,script-path=https://raw.githubusercontent.com/shufflewzc/faker2/main/jd_shop_sign.jss, cronexpr="15 2,14 * * *", timeout=3600, enable=true */ const $ = new Env('店铺签到'); const notify = $.isNode() ? require('./sendNotify') : ''; @@ -25,30 +25,22 @@ let vender='' let num=0 let shopname='' const token = [ - "FEACDDFEABE7E6F5F52E32E79ACB0126", - "113946C00C676DD5141D46EF6194E281", + "30F88897B3C194F5BB7535E62640E00B", "4BF0331BCB845ABC79145753E605E9C3", - "8C00826D27DA33A520F06E5C5C2E302B", "490047103854B8B5E17D3D76C2C65D1D", "F4132FED0919E26A040981E77C3FD009", "3068C74A35718BF761F8E10F52824696", "AF994FA00C2086F08849D5FB7122E79F", "8C172B547FA75FEADBF342CDEBE14C36", - "BA1063C108CD0642AD3A5C21A6952136", + "97CE35E23187041CD746CA5B4E7F4B38", "E20BD5091D8F70B4649D529A09183F04", "88ECFB91288FD2DE93DDBDDAA9409D8E", "1B2F8250713AD30F335B092B70A4DBF5", "642395217049DBC4F56F105B3FBA0633", - "2593927DBC99178C9E835A607D67482C", "8E3E6081738C9C30446C20F347516649", - "C7671CB73E0BE699998307ADB36D8708", - "A795246AE4063905815D7748001C0A58", "57B5F1912B8A5F7C3913EEB0CFA9130B", "C5F5FF51E040B2415A435D5BFDA15348", - "664227400540BC20B0160DE112BE806C", - "B5BD9A190DD6AD49A6E3646CB2700863", "CA4DE825AAE4DCAEC7979216EF6D3451", - "3C17106279994F61484D172F388DDC1D", "7C21504827C3A3923BFAEEC850810301", "EA281B5F2CD68CDA09EE992B1FEA8DDA" ] diff --git a/jd_gjlh.js b/jd_gjlh.js new file mode 100644 index 0000000..b33520b --- /dev/null +++ b/jd_gjlh.js @@ -0,0 +1,337 @@ +/* +[task_local] +#4月京东国际联合活动 +31 1 10-18/3 4 * jd_gjlh.js, tag=4月京东国际联合活动, enabled=true + */ +const $ = new Env('4月京东国际联合活动'); +const notify = $.isNode() ? require('./sendNotify') : ''; +//Node.js用户请在jdCookie.js处填写京东ck; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +let jdNotify = true;//是否关闭通知,false打开通知推送,true关闭通知推送 +$.configCode = "0fa7512ffa1742b5a5f29c1c63bd9a6e"; +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], cookie = '', message; +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 () => { + console.log('入口下拉:https://prodev.m.jd.com/mall/active/48Ki4bRbQFE4izpBis95dxZJSsTq/index.html') + 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 = ''; + 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 jdmodule(); + //await showMsg(); + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + +function showMsg() { + return new Promise(resolve => { + $.msg($.name, '', `【京东账号${$.index}】${$.nickName}\n${message}`); + resolve() + }) +} + + +async function jdmodule() { + let runTime = 0; + do { + await getinfo(); //获取任务 + $.hasFinish = true; + await run(); + runTime++; + } while (!$.hasFinish && runTime < 10); + await getinfo(); + console.log("开始抽奖"); + for (let x = 0; x < $.chanceLeft; x++) { + await join(); + await $.wait(1500) + } +} + +//运行 +async function run() { + try { + for (let vo of $.taskinfo) { + if (vo.hasFinish === true) { + continue; + } + if (vo.taskName == '每日签到') { + console.log(`开始做${vo.taskName}:${vo.taskItem.itemName}`); + await doTask(vo.taskType, vo.taskItem.itemId, vo.id); + await getReward(vo.taskType, vo.taskItem.itemId, vo.id); + } + if (vo.taskType == 3) { + console.log(`开始做${vo.taskName}:${vo.taskItem.itemName}`); + await getinfo2(vo.taskItem.itemLink); + await $.wait(1000 * vo.viewTime) + await doTask(vo.taskType, vo.taskItem.itemId, vo.id); + await getReward(vo.taskType, vo.taskItem.itemId, vo.id); + } + if (vo.taskType == 4) { + console.log(`开始做${vo.taskName}:${vo.taskItem.itemName}`); + await doTask(vo.taskType, vo.taskItem.itemId, vo.id); + await getReward(vo.taskType, vo.taskItem.itemId, vo.id); + } + if (vo.taskType == 2) { + console.log(`开始做${vo.taskName}:${vo.taskItem.itemName}`); + await doTask(vo.taskType, vo.taskItem.itemId, vo.id); + await getReward(vo.taskType, vo.taskItem.itemId, vo.id); + } + $.hasFinish = false; + } + } catch (e) { + console.log(e); + } +} + + +// 获取任务 +function getinfo() { + return new Promise(resolve => { + $.get({ + url: `https://jdjoy.jd.com/module/task/draw/get?configCode=${$.configCode}&unionCardCode=`, + headers: { + 'Host': 'jdjoy.jd.com', + 'accept': '*/*', + 'content-type': 'application/json', + "Referer": "https://prodev.m.jd.com/mall/active/2Rkjx8aT5eKaQnUzn8dwcR6jNanj/index.html", + "origin": "https://prodev.m.jd.com", + 'X-Requested-With': 'com.jingdong.app.mall', + "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-Hans-CN;q=1', + 'cookie': cookie + }, + }, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} getinfo请求失败,请检查网路重试`) + } else { + data = JSON.parse(data); + $.chanceLeft = data.data.chanceLeft; + if (data.success == true) { + $.taskinfo = data.data.taskConfig + } else { + console.log(data.errorMessage); + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }) + }) +} + +//抽奖 +function join() { + return new Promise(async (resolve) => { + $.get({ + url: `https://jdjoy.jd.com/module/task/draw/join?configCode=${$.configCode}&fp=${randomWord(false, 32, 32)}&eid=`, + headers: { + 'Host': 'jdjoy.jd.com', + 'accept': '*/*', + 'content-type': 'application/json', + "Referer": "https://prodev.m.jd.com/mall/active/2Rkjx8aT5eKaQnUzn8dwcR6jNanj/index.html", + "origin": "https://prodev.m.jd.com", + 'X-Requested-With': 'com.jingdong.app.mall', + "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-Hans-CN;q=1', + 'cookie': cookie + }, + }, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`join请求失败,请检查网路重试`) + } else { + data = JSON.parse(data); + if (data.success == true) { + console.log(`抽奖结果:${data.data.rewardName}`); + } + else { + console.log(data.errorMessage); + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }) + }) +} + +//做任务 +function doTask(taskType, itemId, taskid) { + return new Promise(resolve => { + let options = taskPostUrl('doTask', `{"configCode":"${$.configCode}","taskType":${taskType},"itemId":"${itemId}","taskId":${taskid}}`) + $.post(options, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`); + console.log(`doTask 请求失败,请检查网路重试`); + } else { + data = JSON.parse(data); + if (data.success == true) { + console.log("任务成功"); + } else { + console.log(data.errorMessage); + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }); + }); +} + + +//领取任务奖励 +function getReward(taskType, itemId, taskid) { + return new Promise(resolve => { + let options = taskPostUrl('getReward', `{"configCode":"${$.configCode}","taskType":${taskType},"itemId":"${itemId}","taskId":${taskid}}`) + $.post(options, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`); + console.log(`getReward 请求失败,请检查网路重试`); + } else { + data = JSON.parse(data); + if (data.success == true) { + console.log("任务奖励领取成功"); + } else { + console.log(data.errorMessage); + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }); + }); +} + +function getinfo2(url2) { + return new Promise(resolve => { + $.get({ + url: url2, + headers: { + 'Host': 'pro.m.jd.com', + 'accept': '*/*', + 'content-type': 'application/x-www-form-urlencoded', + 'referer': '', + "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-Hans-CN;q=1', + 'cookie': cookie + }, + }, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`getinfo2 API请求失败,请检查网路重试`) + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} + +function taskPostUrl(function_id, body = {}) { + return { + url: `https://jdjoy.jd.com/module/task/draw/${function_id}`, + body: `${(body)}`, + headers: { + "Accept": "application/json, text/plain, */*", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/json", + "Host": "jdjoy.jd.com", + "x-requested-with": "com.jingdong.app.mall", + "Referer": "https://prodev.m.jd.com/mall/active/2Rkjx8aT5eKaQnUzn8dwcR6jNanj/index.html", + "origin": "https://prodev.m.jd.com", + "Cookie": cookie, + "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"), + } + } +} + +function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + +function randomWord(randomFlag, min, max) { + var str = "", + range = min, + arr = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']; + + // 随机产生 + if (randomFlag) { + range = Math.round(Math.random() * (max - min)) + min; + } + for (var i = 0; i < range; i++) { + pos = Math.round(Math.random() * (arr.length - 1)); + str += arr[pos]; + } + return str; +} +// prettier-ignore +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.data[t]||null}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){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=(()=>{})){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)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)})):this.isQuanX()?(this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t))):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{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){this.logErr(t)}}).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)}))}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,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t));else if(this.isNode()){this.initGotEnv(t);const{url:s,...i}=t;this.got.post(s,i).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)})}}time(t,e=null){const s=e?new Date(e):new Date;let i={"M+":s.getMonth()+1,"d+":s.getDate(),"H+":s.getHours(),"m+":s.getMinutes(),"s+":s.getSeconds(),"q+":Math.floor((s.getMonth()+3)/3),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)));return t}msg(e=t,s="",i="",r){const o=t=>{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()){let e=t.openUrl||t.url||t["open-url"],s=t.mediaUrl||t["media-url"];return{openUrl:e,mediaUrl:s}}if(this.isQuanX()){let e=t["open-url"]||t.url||t.openUrl,s=t["media-url"]||t.mediaUrl;return{"open-url":e,"media-url":s}}if(this.isSurge()){let e=t.url||t.openUrl||t["open-url"];return{url: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){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){t.length>0&&(this.logs=[...this.logs,...t]),console.log(t.join(this.logSeparator))}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){return new Promise(e=>setTimeout(e,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)}}(t,e)} diff --git a/jd_health.js b/jd_health.js index 7510280..94aa03a 100644 --- a/jd_health.js +++ b/jd_health.js @@ -7,36 +7,32 @@ ===================quantumultx================ [task_local] #东东健康社区 -13 0,6,22 * * * jd_health.js, tag=东东健康社区, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true +13 1,6,22 * * * https://raw.githubusercontent.com/shufflewzc/faker2/main/jd_health.js, tag=东东健康社区, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true =====================Loon================ [Script] -cron "13 0,6,22 * * *" script-path=jd_health.js, tag=东东健康社区 +cron "13 1,6,22 * * *" script-path=https://raw.githubusercontent.com/shufflewzc/faker2/main/jd_health.js, tag=东东健康社区 ====================Surge================ -东东健康社区 = type=cron,cronexp="13 0,6,22 * * *",wake-system=1,timeout=3600,script-path=jd_health.js +东东健康社区 = type=cron,cronexp="13 1,6,22 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/shufflewzc/faker2/main/jd_health.js ============小火箭========= -东东健康社区 = type=cron,script-path=jd_health.js, cronexpr="13 0,6,22 * * *", timeout=3600, enable=true +东东健康社区 = type=cron,script-path=https://raw.githubusercontent.com/shufflewzc/faker2/main/jd_health.js, cronexpr="13 1,6,22 * * *", timeout=3600, enable=true */ const $ = new Env("东东健康社区"); const jdCookieNode = $.isNode() ? require("./jdCookie.js") : ""; const notify = $.isNode() ? require('./sendNotify') : ""; let cookiesArr = [], cookie = "", allMessage = "", message; -const inviteCodes = [ - `T0225KkcRh9P9FbRKUygl_UJcgCjVfnoaW5kRrbA@T0159KUiH11Mq1bSKBoCjVfnoaW5kRrbA@T018v_hzQhwZ8FbUIRib1ACjVfnoaW5kRrbA`, - `T0225KkcRh9P9FbRKUygl_UJcgCjVfnoaW5kRrbA@T0159KUiH11Mq1bSKBoCjVfnoaW5kRrbA@T018v_hzQhwZ8FbUIRib1ACjVfnoaW5kRrbA`, - `T0225KkcRh9P9FbRKUygl_UJcgCjVfnoaW5kRrbA@T0159KUiH11Mq1bSKBoCjVfnoaW5kRrbA@T018v_hzQhwZ8FbUIRib1ACjVfnoaW5kRrbA`, -] -const ZLC = !(process.env.JD_JOIN_ZLC && process.env.JD_JOIN_ZLC === 'false') let reward = process.env.JD_HEALTH_REWARD_NAME ? process.env.JD_HEALTH_REWARD_NAME : '' const randomCount = $.isNode() ? 20 : 5; -function oc(fn, defaultVal) {//optioanl chaining - try { - return fn() - } catch (e) { - return undefined - } +$.newShareCodes = []; +let UserShareCodes = ""; +function oc(fn, defaultVal) { //optioanl chaining + try { + return fn() + } catch (e) { + return undefined + } } function nc(val1, val2) {//nullish coalescing return val1 != undefined ? val1 : val2 @@ -47,7 +43,7 @@ if ($.isNode()) { }); if (process.env.JD_DEBUG && process.env.JD_DEBUG === "false") console.log = () => {}; } else { - cookiesArr = [$.getdata("CookieJD"), $.getdata("CookieJD2"), ...$.toObj($.getdata("CookiesJD") || "[]").map((item) => item.cookie)].filter((item) => !!item); + cookiesArr = [$.getdata("CookieJD"), $.getdata("CookieJD2"), ...$.toObj($.getdata("CookiesJD") || "[]").map((item) => item.cookie)].filter((item) => !!item); } const JD_API_HOST = "https://api.m.jd.com/"; !(async () => { @@ -55,39 +51,31 @@ const JD_API_HOST = "https://api.m.jd.com/"; $.msg($.name, "【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取", "https://bean.m.jd.com/", {"open-url": "https://bean.m.jd.com/"}); return; } - if (!process.env.JD_JOIN_ZLC) { - console.log(`【注意】本脚本默认会给助力池进行助力!\n如需加入助力池请添加TG群:https://t.me/jd_zero_205\n如不加入助力池互助,可添加变量名称:JD_JOIN_ZLC,变量值:false\n`) - } - await requireConfig() - 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; - message = ""; - console.log(`\n******开始【京东账号${$.index}】${$.UserName}*********\n`); - await shareCodesFormat() - await main() - await showMsg() - } - } - if ($.isNode() && allMessage) { - await notify.sendNotify(`${$.name}`, `${allMessage}`) - } + console.log(`开始执行任务....\n`); + 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; + message = ""; + console.log(`\n******开始【京东账号${$.index}】${$.UserName}*********\n`); + await main() + await showMsg() + } + } + if ($.isNode() && allMessage) { + await notify.sendNotify(`${$.name}`, `${allMessage}`) + } })() - .catch((e) => { - $.log("", `❌ ${$.name}, 失败! 原因: ${e}!`, ""); - }) - .finally(() => { - $.done(); - }); +.catch((e) => { + $.log("", `❌ ${$.name}, 失败! 原因: ${e}!`, ""); +}) +.finally(() => { + $.done(); +}); async function main() { - try { - if (reward) { - await getCommodities() - } - + try { $.score = 0 $.earn = false await getTaskDetail(-1) @@ -100,34 +88,25 @@ async function main() { await $.wait(1000) } await collectScore() - await helpFriends() await getTaskDetail(22); await getTaskDetail(-1) + if (reward) { + await getCommodities() + } + await exchanges() + } catch (e) { $.logErr(e) - } -} - -async function helpFriends() { - for (let code of $.newShareCodes) { - if (!code) continue - console.log(`去助力好友${code}`) - let res = await doTask(code, 6) - if([108,-1001].includes(oc(() => res.data.bizCode))){ - console.log(`助力次数已满,跳出`) - break - } - await $.wait(1000) - } + } } function showMsg() { - return new Promise(async resolve => { - message += `本次获得${$.earn}健康值,累计${$.score}健康值\n` - $.msg($.name, '', `京东账号${$.index} ${$.UserName}\n${message}`); - resolve(); - }) + return new Promise(async resolve => { + message += `本次获得${$.earn}健康值,累计${$.score}健康值\n` + $.msg($.name, '', `京东账号${$.index} ${$.UserName}\n${message}`); + resolve(); + }) } function getTaskDetail(taskId = '') { @@ -149,24 +128,7 @@ function getTaskDetail(taskId = '') { } else if (taskId === 6) { if (oc(() => data.data.result.taskVos)) { console.log(`\n【京东账号${$.index}(${$.UserName})的${$.name}好友互助码】${oc(() => data.data.result.taskVos[0].assistTaskDetailVo.taskToken)}\n`); - // console.log('好友助力码:' + oc(() => data.data.result.taskVos[0].assistTaskDetailVo.taskToken)) - // *************************** - // 报告运行次数 - if (ZLC) { - if (oc(() => data.data.result.taskVos[0].assistTaskDetailVo.taskToken)) { - $.code = data.data.result.taskVos[0].assistTaskDetailVo.taskToken - for (let k = 0; k < 5; k++) { - try { - await runTimes() - break - } catch (e) { - } - await $.wait(Math.floor(Math.random() * 10 + 3) * 1000) - } - } - } - // *************************** - + // console.log('好友助力码:' + data?.data?.result?.taskVos[0].assistTaskDetailVo.taskToken) } } else if (taskId === 22) { console.log(`${oc(() => data.data.result.taskVos[0].taskName)}任务,完成次数:${oc(() => data.data.result.taskVos[0].times)}/${oc(() => data.data.result.taskVos[0].maxTimes)}`) @@ -215,21 +177,30 @@ function getTaskDetail(taskId = '') { }) }) } -function runTimes() { - return new Promise((resolve, reject) => { - $.get({ - url: `https://api.jdsharecode.xyz/api/runTimes?activityId=health&sharecode=${$.code}` - }, (err, resp, data) => { - if (err) { - console.log('上报失败', err) - reject(err) - } else { - console.log(data) - resolve() + +function exchanges(commodityType, commodityId) { + return new Promise(resolve => { + const options = taskUrl('jdhealth_doLottery', {"taskId":1}) + $.post(options, (err, resp, data) => { + try { + if (safeGet(data)) { + data = $.toObj(data) + if (data.data.bizCode === 0 || data.data.bizMsg === "success") { + $.score = data.data.result.jingBeanNum + console.log(`领取${data.data.result.jingBeanNum}京豆成功`) + } else { + console.log(data.data.bizMsg) + } + } + } catch (e) { + console.log(e) + } finally { + resolve(data) } }) }) } + async function getCommodities() { return new Promise(async resolve => { const options = taskUrl('jdhealth_getCommodities') @@ -338,111 +309,32 @@ function collectScore() { } function taskUrl(function_id, body = {}) { - return { - url: `${JD_API_HOST}?functionId=${function_id}&body=${escape(JSON.stringify(body))}&client=wh5&clientVersion=1.0.0&uuid=`, - headers: { - "Cookie": cookie, - "origin": "https://h5.m.jd.com", - "referer": "https://h5.m.jd.com/", - 'accept-language': 'zh-cn', - 'accept-encoding': 'gzip, deflate, br', - 'accept': 'application/json, text/plain, */*', - '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") - } - } + return { + url: `${JD_API_HOST}?functionId=${function_id}&body=${escape(JSON.stringify(body))}&client=wh5&clientVersion=1.0.0&uuid=`, + headers: { + "Cookie": cookie, + "origin": "https://h5.m.jd.com", + "referer": "https://h5.m.jd.com/", + 'accept-language': 'zh-cn', + 'accept-encoding': 'gzip, deflate, br', + 'accept': 'application/json, text/plain, */*', + '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") + } + } } function safeGet(data) { - try { - if (typeof JSON.parse(data) == "object") { - return true; - } - } catch (e) { - console.log(e); - console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); - return false; - } + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); + return false; + } } -function readShareCode() { - console.log(`开始`) - return new Promise(async resolve => { - $.get({ - url: `https://api.jdsharecode.xyz/api/health/${randomCount}`, - 'timeout': 10000 - }, (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`${$.name} health/read 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('@'); - } - if (!ZLC) { - console.log(`您设置了不加入助力池,跳过\n`) - } else { - const readShareCodeRes = await readShareCode(); - if (readShareCodeRes && readShareCodeRes.code === 200) { - $.newShareCodes = [...new Set([...$.newShareCodes, ...(readShareCodeRes.data || [])])]; - } - } - console.log(`第${$.index}个京东账号将要助力的好友${JSON.stringify($.newShareCodes)}`) - resolve(); - }) -} - -function requireConfig() { - return new Promise(resolve => { - console.log(`开始获取${$.name}配置文件\n`); - //Node.js用户请在jdCookie.js处填写京东ck; - let shareCodes = []; - if ($.isNode()) { - if (process.env.JDHEALTH_SHARECODES) { - if (process.env.JDHEALTH_SHARECODES.indexOf('\n') > -1) { - shareCodes = process.env.JDHEALTH_SHARECODES.split('\n'); - } else { - shareCodes = process.env.JDHEALTH_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() - }) -} // prettier-ignore 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.data[t]||null}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){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=(()=>{})){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)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)})):this.isQuanX()?(this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t))):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{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){this.logErr(t)}}).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)}))}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,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t));else if(this.isNode()){this.initGotEnv(t);const{url:s,...i}=t;this.got.post(s,i).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)})}}time(t,e=null){const s=e?new Date(e):new Date;let i={"M+":s.getMonth()+1,"d+":s.getDate(),"H+":s.getHours(),"m+":s.getMinutes(),"s+":s.getSeconds(),"q+":Math.floor((s.getMonth()+3)/3),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)));return t}msg(e=t,s="",i="",r){const o=t=>{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()){let e=t.openUrl||t.url||t["open-url"],s=t.mediaUrl||t["media-url"];return{openUrl:e,mediaUrl:s}}if(this.isQuanX()){let e=t["open-url"]||t.url||t.openUrl,s=t["media-url"]||t.mediaUrl;return{"open-url":e,"media-url":s}}if(this.isSurge()){let e=t.url||t.openUrl||t["open-url"];return{url: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){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){t.length>0&&(this.logs=[...this.logs,...t]),console.log(t.join(this.logSeparator))}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){return new Promise(e=>setTimeout(e,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)}}(t,e)} diff --git a/jd_mncryyj.js b/jd_mncryyj.js new file mode 100644 index 0000000..e4fdf92 --- /dev/null +++ b/jd_mncryyj.js @@ -0,0 +1,337 @@ +/* +[task_local] +#4月蒙牛春日音乐节抽奖机 +31 14 9-21/3 4 * jd_mncryyj.js, tag=4月蒙牛春日音乐节抽奖机, enabled=true + */ +const $ = new Env('4月蒙牛春日音乐节抽奖机'); +const notify = $.isNode() ? require('./sendNotify') : ''; +//Node.js用户请在jdCookie.js处填写京东ck; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +let jdNotify = true;//是否关闭通知,false打开通知推送,true关闭通知推送 +$.configCode = "445d31ec3db740b992b2f6798c0fd646"; +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], cookie = '', message; +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 () => { + console.log('入口下拉:https://prodev.m.jd.com/mall/active/ymjgzZHsgzyCr2zoDcg7wrgEZLK/index.html') + 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 = ''; + 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 jdmodule(); + //await showMsg(); + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + +function showMsg() { + return new Promise(resolve => { + $.msg($.name, '', `【京东账号${$.index}】${$.nickName}\n${message}`); + resolve() + }) +} + + +async function jdmodule() { + let runTime = 0; + do { + await getinfo(); //获取任务 + $.hasFinish = true; + await run(); + runTime++; + } while (!$.hasFinish && runTime < 10); + await getinfo(); + console.log("开始抽奖"); + for (let x = 0; x < $.chanceLeft; x++) { + await join(); + await $.wait(1500) + } +} + +//运行 +async function run() { + try { + for (let vo of $.taskinfo) { + if (vo.hasFinish === true) { + continue; + } + if (vo.taskName == '每日签到') { + console.log(`开始做${vo.taskName}:${vo.taskItem.itemName}`); + await doTask(vo.taskType, vo.taskItem.itemId, vo.id); + await getReward(vo.taskType, vo.taskItem.itemId, vo.id); + } + if (vo.taskType == 3) { + console.log(`开始做${vo.taskName}:${vo.taskItem.itemName}`); + await getinfo2(vo.taskItem.itemLink); + await $.wait(1000 * vo.viewTime) + await doTask(vo.taskType, vo.taskItem.itemId, vo.id); + await getReward(vo.taskType, vo.taskItem.itemId, vo.id); + } + if (vo.taskType == 4) { + console.log(`开始做${vo.taskName}:${vo.taskItem.itemName}`); + await doTask(vo.taskType, vo.taskItem.itemId, vo.id); + await getReward(vo.taskType, vo.taskItem.itemId, vo.id); + } + if (vo.taskType == 2) { + console.log(`开始做${vo.taskName}:${vo.taskItem.itemName}`); + await doTask(vo.taskType, vo.taskItem.itemId, vo.id); + await getReward(vo.taskType, vo.taskItem.itemId, vo.id); + } + $.hasFinish = false; + } + } catch (e) { + console.log(e); + } +} + + +// 获取任务 +function getinfo() { + return new Promise(resolve => { + $.get({ + url: `https://jdjoy.jd.com/module/task/draw/get?configCode=${$.configCode}&unionCardCode=`, + headers: { + 'Host': 'jdjoy.jd.com', + 'accept': '*/*', + 'content-type': 'application/json', + "Referer": "https://prodev.m.jd.com/mall/active/2Rkjx8aT5eKaQnUzn8dwcR6jNanj/index.html", + "origin": "https://prodev.m.jd.com", + 'X-Requested-With': 'com.jingdong.app.mall', + "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-Hans-CN;q=1', + 'cookie': cookie + }, + }, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} getinfo请求失败,请检查网路重试`) + } else { + data = JSON.parse(data); + $.chanceLeft = data.data.chanceLeft; + if (data.success == true) { + $.taskinfo = data.data.taskConfig + } else { + console.log(data.errorMessage); + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }) + }) +} + +//抽奖 +function join() { + return new Promise(async (resolve) => { + $.get({ + url: `https://jdjoy.jd.com/module/task/draw/join?configCode=${$.configCode}&fp=${randomWord(false, 32, 32)}&eid=`, + headers: { + 'Host': 'jdjoy.jd.com', + 'accept': '*/*', + 'content-type': 'application/json', + "Referer": "https://prodev.m.jd.com/mall/active/2Rkjx8aT5eKaQnUzn8dwcR6jNanj/index.html", + "origin": "https://prodev.m.jd.com", + 'X-Requested-With': 'com.jingdong.app.mall', + "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-Hans-CN;q=1', + 'cookie': cookie + }, + }, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`join请求失败,请检查网路重试`) + } else { + data = JSON.parse(data); + if (data.success == true) { + console.log(`抽奖结果:${data.data.rewardName}`); + } + else { + console.log(data.errorMessage); + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }) + }) +} + +//做任务 +function doTask(taskType, itemId, taskid) { + return new Promise(resolve => { + let options = taskPostUrl('doTask', `{"configCode":"${$.configCode}","taskType":${taskType},"itemId":"${itemId}","taskId":${taskid}}`) + $.post(options, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`); + console.log(`doTask 请求失败,请检查网路重试`); + } else { + data = JSON.parse(data); + if (data.success == true) { + console.log("任务成功"); + } else { + console.log(data.errorMessage); + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }); + }); +} + + +//领取任务奖励 +function getReward(taskType, itemId, taskid) { + return new Promise(resolve => { + let options = taskPostUrl('getReward', `{"configCode":"${$.configCode}","taskType":${taskType},"itemId":"${itemId}","taskId":${taskid}}`) + $.post(options, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`); + console.log(`getReward 请求失败,请检查网路重试`); + } else { + data = JSON.parse(data); + if (data.success == true) { + console.log("任务奖励领取成功"); + } else { + console.log(data.errorMessage); + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }); + }); +} + +function getinfo2(url2) { + return new Promise(resolve => { + $.get({ + url: url2, + headers: { + 'Host': 'pro.m.jd.com', + 'accept': '*/*', + 'content-type': 'application/x-www-form-urlencoded', + 'referer': '', + "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-Hans-CN;q=1', + 'cookie': cookie + }, + }, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`getinfo2 API请求失败,请检查网路重试`) + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} + +function taskPostUrl(function_id, body = {}) { + return { + url: `https://jdjoy.jd.com/module/task/draw/${function_id}`, + body: `${(body)}`, + headers: { + "Accept": "application/json, text/plain, */*", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/json", + "Host": "jdjoy.jd.com", + "x-requested-with": "com.jingdong.app.mall", + "Referer": "https://prodev.m.jd.com/mall/active/2Rkjx8aT5eKaQnUzn8dwcR6jNanj/index.html", + "origin": "https://prodev.m.jd.com", + "Cookie": cookie, + "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"), + } + } +} + +function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + +function randomWord(randomFlag, min, max) { + var str = "", + range = min, + arr = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']; + + // 随机产生 + if (randomFlag) { + range = Math.round(Math.random() * (max - min)) + min; + } + for (var i = 0; i < range; i++) { + pos = Math.round(Math.random() * (arr.length - 1)); + str += arr[pos]; + } + return str; +} +// prettier-ignore +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.data[t]||null}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){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=(()=>{})){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)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)})):this.isQuanX()?(this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t))):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{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){this.logErr(t)}}).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)}))}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,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t));else if(this.isNode()){this.initGotEnv(t);const{url:s,...i}=t;this.got.post(s,i).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)})}}time(t,e=null){const s=e?new Date(e):new Date;let i={"M+":s.getMonth()+1,"d+":s.getDate(),"H+":s.getHours(),"m+":s.getMinutes(),"s+":s.getSeconds(),"q+":Math.floor((s.getMonth()+3)/3),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)));return t}msg(e=t,s="",i="",r){const o=t=>{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()){let e=t.openUrl||t.url||t["open-url"],s=t.mediaUrl||t["media-url"];return{openUrl:e,mediaUrl:s}}if(this.isQuanX()){let e=t["open-url"]||t.url||t.openUrl,s=t["media-url"]||t.mediaUrl;return{"open-url":e,"media-url":s}}if(this.isSurge()){let e=t.url||t.openUrl||t["open-url"];return{url: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){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){t.length>0&&(this.logs=[...this.logs,...t]),console.log(t.join(this.logSeparator))}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){return new Promise(e=>setTimeout(e,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)}}(t,e)} diff --git a/jd_speed_10_4.js b/jd_speed_10_4.js index db5d64c..28a4f22 100644 --- a/jd_speed_10_4.js +++ b/jd_speed_10_4.js @@ -4,14 +4,14 @@ ============Quantumultx=============== [task_local] #极速版抢卷 -58 59 7,10,13,15,19 * * * https://raw.githubusercontent.com/KingRan/KR/main/jd_10_4.js, tag=极速版抢卷, enabled=true +58 59 7,10,13,15,19 * * * https://raw.githubusercontent.com/shufflewzc/faker2/main/jd_10_4.js, tag=极速版抢卷, enabled=true ================Loon============== [Script] -cron "58 59 7,10,13,15,19 * * *" script-path=https://raw.githubusercontent.com/KingRan/KR/main/jd_10_4.js,tag=极速版抢卷 +cron "58 59 7,10,13,15,19 * * *" script-path=https://raw.githubusercontent.com/shufflewzc/faker2/main/jd_10_4.js,tag=极速版抢卷 ===============Surge================= -极速版抢卷 = type=cron,cronexp="58 59 7,10,13,15,19 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/KingRan/KR/main/jd_10_4.js +极速版抢卷 = type=cron,cronexp="58 59 7,10,13,15,19 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/shufflewzc/faker2/main/jd_10_4.js ============小火箭========= -极速版抢卷 = type=cron,script-path=https://raw.githubusercontent.com/KingRan/KR/main/jd_10_4.js, cronexpr="58 59 7,10,13,15,19 * * *", timeout=3600, enable=true +极速版抢卷 = type=cron,script-path=https://raw.githubusercontent.com/shufflewzc/faker2/main/jd_10_4.js, cronexpr="58 59 7,10,13,15,19 * * *", timeout=3600, enable=true */ const $ = new Env('抢极速版全品卷10-4'); const moment = require('moment'); diff --git a/jd_speed_19_6.js b/jd_speed_19_6.js index edd2de2..c1e88e4 100644 --- a/jd_speed_19_6.js +++ b/jd_speed_19_6.js @@ -4,14 +4,14 @@ ============Quantumultx=============== [task_local] #极速版抢卷 -58 59 6,9,14,17,20 * * * https://raw.githubusercontent.com/KingRan/KR/main/jd_19_6.js, tag=极速版抢卷, enabled=true +58 59 6,9,14,17,20 * * * https://raw.githubusercontent.com/shufflewzc/faker2/main/jd_19_6.js, tag=极速版抢卷, enabled=true ================Loon============== [Script] -cron "58 59 6,9,14,17,20 * * *" script-path=https://raw.githubusercontent.com/KingRan/KR/main/jd_19_6.js,tag=极速版抢卷 +cron "58 59 6,9,14,17,20 * * *" script-path=https://raw.githubusercontent.com/shufflewzc/faker2/main/jd_19_6.js,tag=极速版抢卷 ===============Surge================= -极速版抢卷 = type=cron,cronexp="58 59 6,9,14,17,20 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/KingRan/KR/main/jd_19_6.js +极速版抢卷 = type=cron,cronexp="58 59 6,9,14,17,20 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/shufflewzc/faker2/main/jd_19_6.js ============小火箭========= -极速版抢卷 = type=cron,script-path=https://raw.githubusercontent.com/KingRan/KR/main/jd_19_6.js, cronexpr="58 59 6,9,14,17,20 * * *", timeout=3600, enable=true +极速版抢卷 = type=cron,script-path=https://raw.githubusercontent.com/shufflewzc/faker2/main/jd_19_6.js, cronexpr="58 59 6,9,14,17,20 * * *", timeout=3600, enable=true */ const $ = new Env('抢极速版全品卷19-6'); const moment = require('moment'); diff --git a/jd_speed_29_8.js b/jd_speed_29_8.js index 3f59a35..3cb55e3 100644 --- a/jd_speed_29_8.js +++ b/jd_speed_29_8.js @@ -4,14 +4,14 @@ ============Quantumultx=============== [task_local] #极速版抢卷 -58 59 8,11,14,16,19 * * * https://raw.githubusercontent.com/KingRan/KR/main/jd_29_8.js, tag=极速版抢卷, enabled=true +58 59 8,11,14,16,19 * * * https://raw.githubusercontent.com/shufflewzc/faker2/main/jd_29_8.js, tag=极速版抢卷, enabled=true ================Loon============== [Script] -cron "58 59 8,11,14,16,19 * * *" script-path=https://raw.githubusercontent.com/KingRan/KR/main/jd_29_8.js,tag=极速版抢卷 +cron "58 59 8,11,14,16,19 * * *" script-path=https://raw.githubusercontent.com/shufflewzc/faker2/main/jd_29_8.js,tag=极速版抢卷 ===============Surge================= -极速版抢卷 = type=cron,cronexp="58 59 8,11,14,16,19 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/KingRan/KR/main/jd_29_8.js +极速版抢卷 = type=cron,cronexp="58 59 8,11,14,16,19 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/shufflewzc/faker2/main/jd_29_8.js ============小火箭========= -极速版抢卷 = type=cron,script-path=https://raw.githubusercontent.com/KingRan/KR/main/jd_29_8.js, cronexpr="58 59 8,11,14,16,19 * * *", timeout=3600, enable=true +极速版抢卷 = type=cron,script-path=https://raw.githubusercontent.com/shufflewzc/faker2/main/jd_29_8.js, cronexpr="58 59 8,11,14,16,19 * * *", timeout=3600, enable=true */ const $ = new Env('抢极速版全品卷29-8'); const moment = require('moment'); diff --git a/jd_speed_5_2.js b/jd_speed_5_2.js index 7a3e9d7..08d4464 100644 --- a/jd_speed_5_2.js +++ b/jd_speed_5_2.js @@ -4,14 +4,14 @@ ============Quantumultx=============== [task_local] #极速版抢卷 -58 59 6,9,14,17,20 * * * https://raw.githubusercontent.com/KingRan/KR/main/jd_5_2.js, tag=极速版抢卷, enabled=true +58 59 6,9,14,17,20 * * * https://raw.githubusercontent.com/shufflewzc/faker2/main/jd_5_2.js, tag=极速版抢卷, enabled=true ================Loon============== [Script] -cron "58 59 6,9,14,17,20 * * *" script-path=https://raw.githubusercontent.com/KingRan/KR/main/jd_5_2.js,tag=极速版抢卷 +cron "58 59 6,9,14,17,20 * * *" script-path=https://raw.githubusercontent.com/shufflewzc/faker2/main/jd_5_2.js,tag=极速版抢卷 ===============Surge================= -极速版抢卷 = type=cron,cronexp="58 59 6,9,14,17,20 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/KingRan/KR/main/jd_5_2.js +极速版抢卷 = type=cron,cronexp="58 59 6,9,14,17,20 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/shufflewzc/faker2/main/jd_5_2.js ============小火箭========= -极速版抢卷 = type=cron,script-path=https://raw.githubusercontent.com/KingRan/KR/main/jd_5_2.js, cronexpr="58 59 6,9,14,17,20 * * *", timeout=3600, enable=true +极速版抢卷 = type=cron,script-path=https://raw.githubusercontent.com/shufflewzc/faker2/main/jd_5_2.js, cronexpr="58 59 6,9,14,17,20 * * *", timeout=3600, enable=true */ const $ = new Env('抢极速版全品卷5-2'); const moment = require('moment'); diff --git a/jd_wish.js b/jd_wish.js index e1e7eeb..1f92cc8 100644 --- a/jd_wish.js +++ b/jd_wish.js @@ -5,17 +5,17 @@ ===============Quantumultx=============== [task_local] #众筹许愿池 -40 0,2 * * * https://raw.githubusercontent.com/222222/sync/jd_scripts/jd_wish.js, tag=众筹许愿池, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true +40 0,2 * * * https://raw.githubusercontent.com/KingRan/JDJB/main/jd_wish.js, tag=众筹许愿池, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true ================Loon============== [Script] -cron "40 0,2 * * *" script-path=https://raw.githubusercontent.com/222222/sync/jd_scripts/jd_wish.js,tag=众筹许愿池 +cron "40 0,2 * * *" script-path=https://raw.githubusercontent.com/KingRan/JDJB/main/jd_wish.js,tag=众筹许愿池 ===============Surge================= -众筹许愿池 = type=cron,cronexp="40 0,2 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/222222/sync/jd_scripts/jd_wish.js +众筹许愿池 = type=cron,cronexp="40 0,2 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/KingRan/JDJB/main/jd_wish.js ============小火箭========= -众筹许愿池 = type=cron,script-path=https://raw.githubusercontent.com/222222/sync/jd_scripts/jd_wish.js, cronexpr="40 0,2 * * *", timeout=3600, enable=true +众筹许愿池 = type=cron,script-path=https://raw.githubusercontent.com/KingRan/JDJB/main/jd_wish.js, cronexpr="40 0,2 * * *", timeout=3600, enable=true */ const $ = new Env('众筹许愿池'); const notify = $.isNode() ? require('./sendNotify') : ''; @@ -25,8 +25,8 @@ let message = '', allMessage = ''; //IOS等用户直接用NobyDa的jd cookie let cookiesArr = [], cookie = ''; const JD_API_HOST = 'https://api.m.jd.com/client.action'; -let appIdArr = ['1EFdRwqyF','1EFZWxKqP','1FFVQyqw','1EFRQwA','1EFRWxKuG', '1E1xZy6s']; -let appNameArr = ['春尚','新品来袭','1111点心动','疯狂砸金蛋','许愿抽好礼', 'PLUS生活特权']; +let appIdArr = ['1FFVQyqw','1EFRWxKuG', '1E1xZy6s']; +let appNameArr = ['1111点心动','许愿抽好礼', 'PLUS生活特权']; let appId, appName; $.shareCode = []; if ($.isNode()) { @@ -72,12 +72,7 @@ if ($.isNode()) { if ($.isNode()) await notify.sendNotify($.name, allMessage); $.msg($.name, '', allMessage) } - let res = await getAuthorShareCode('https://raw.githubusercontent.com/222222/11111128/master/shareCodes/11111127') - if (!res) { - $.http.get({url: 'https://purge.jsdelivr.net/gh/222222/11111128@master/shareCodes/11111127'}).then((resp) => {}).catch((e) => console.log('刷新CDN异常', e)); - await $.wait(1000) - res = await getAuthorShareCode('https://cdn.jsdelivr.net/gh/222222/11111128@master/shareCodes/11111127') - } + let res = await getAuthorShareCode('https://gitee.com/KingRan521/JD-Scripts/raw/master/shareCodes/wish.json') $.shareCode = [...$.shareCode, ...(res || [])] for (let i = 0; i < cookiesArr.length; i++) { if (cookiesArr[i]) { @@ -136,7 +131,6 @@ async function jd_wish() { await interact_template_getLotteryResult() await $.wait(2000) } - if (message) allMessage += `京东账号${$.index} ${$.nickName || $.UserName}\n${appName}\n${message}${$.index !== cookiesArr.length ? '\n\n' : ''}` } catch (e) { $.logErr(e) @@ -145,7 +139,8 @@ async function jd_wish() { async function healthyDay_getHomeData(type = true) { return new Promise(async resolve => { - $.post(taskUrl('healthyDay_getHomeData', {"appId":appId,"taskToken":"","channelId":1}), async (err, resp, data) => { + // console.log(taskUrl('healthyDay_getHomeData', { "appId": appId, "taskToken": "", "channelId": 1 })); + $.post(taskUrl('healthyDay_getHomeData', { "appId": appId, "taskToken": "", "channelId": 1 }), async (err, resp, data) => { try { if (err) { console.log(`${JSON.stringify(err)}`) @@ -153,47 +148,72 @@ async function healthyDay_getHomeData(type = true) { } else { if (safeGet(data)) { data = JSON.parse(data); + // console.log(data); if (type) { + for (let key of Object.keys(data.data.result.hotTaskVos).reverse()) { + let vo = data.data.result.hotTaskVos[key] + if (vo.status !== 2) { + if (vo.taskType === 12) { + console.log(`点击热区`) + await harmony_collectScore({"appId":appId,"taskToken":vo.simpleRecordInfoVo.taskToken,"taskId":vo.taskId,"actionType":"0"}, vo.taskType) + } + }else { + console.log(`【${vo.taskName}】已完成\n`) + } + } for (let key of Object.keys(data.data.result.taskVos).reverse()) { let vo = data.data.result.taskVos[key] - if (vo.status !== 2 && vo.status !== 0) { + if (vo.status !== 2) { if (vo.taskType === 13 || vo.taskType === 12) { console.log(`签到`) - await harmony_collectScore({"appId":appId,"taskToken":vo.simpleRecordInfoVo.taskToken,"taskId":vo.taskId,"actionType":"0"}, vo.taskType) + await harmony_collectScore({ "appId": appId, "taskToken": vo.simpleRecordInfoVo.taskToken, "taskId": vo.taskId, "actionType": "0" }, vo.taskType) } else if (vo.taskType === 1) { - $.complete = false; for (let key of Object.keys(vo.followShopVo)) { let followShopVo = vo.followShopVo[key] if (followShopVo.status !== 2) { console.log(`【${followShopVo.shopName}】${vo.subTitleName}`) - await harmony_collectScore({"appId":appId,"taskToken":followShopVo.taskToken,"taskId":vo.taskId,"actionType":"0"}) - if ($.complete) break; + await harmony_collectScore({ "appId": appId, "taskToken": followShopVo.taskToken, "taskId": vo.taskId, "actionType": "0" }) } } - } else if (vo.taskType === 8) { - $.complete = false; + } else if (vo.taskType === 5) { + for (let key of Object.keys(vo.browseShopVo)) { + let browseShopVo = vo.browseShopVo[key] + if (browseShopVo.status !== 2) { + console.log(`【${browseShopVo.skuName}】${vo.subTitleName}`) + await harmony_collectScore({ "appId": appId, "taskToken": browseShopVo.taskToken, "taskId": vo.taskId, "actionType": "0" }) + } + } + } else if (vo.taskType === 15) { for (let key of Object.keys(vo.productInfoVos)) { let productInfoVos = vo.productInfoVos[key] if (productInfoVos.status !== 2) { console.log(`【${productInfoVos.skuName}】${vo.subTitleName}`) - await harmony_collectScore({"appId":appId,"taskToken":productInfoVos.taskToken,"taskId":vo.taskId,"actionType":"1"}) - await $.wait(vo.waitDuration * 1000) - await harmony_collectScore({"appId":appId,"taskToken":productInfoVos.taskToken,"taskId":vo.taskId,"actionType":"0"}) - if ($.complete) break; + await harmony_collectScore({ "appId": appId, "taskToken": productInfoVos.taskToken, "taskId": vo.taskId, "actionType": "0" }) } } + } else if (vo.taskType === 8) { + for (let key of Object.keys(vo.productInfoVos)) { + let productInfoVos = vo.productInfoVos[key] + if (productInfoVos.status !== 2) { + console.log(`【${productInfoVos.skuName}】${vo.subTitleName}`) + await harmony_collectScore({ "appId": appId, "taskToken": productInfoVos.taskToken, "taskId": vo.taskId, "actionType": "1" }) + await $.wait(vo.waitDuration * 1000) + await harmony_collectScore({ "appId": appId, "taskToken": productInfoVos.taskToken, "taskId": vo.taskId, "actionType": "0" }) + } + } + } else if (vo.taskType === 27 && vo.taskId === 18) { + console.log(`【${vo.subTitleName}】`) + await harmony_collectScore({ "appId": appId, "taskToken": vo.productInfoVos[0].taskToken, "taskId": vo.taskId, "actionType": "0" }) } else if (vo.taskType === 9 || vo.taskType === 26) { - $.complete = false; for (let key of Object.keys(vo.shoppingActivityVos)) { let shoppingActivityVos = vo.shoppingActivityVos[key] if (shoppingActivityVos.status !== 2) { console.log(`【${shoppingActivityVos.title}】${vo.subTitleName}`) if (vo.taskType === 9) { - await harmony_collectScore({"appId":appId,"taskToken":shoppingActivityVos.taskToken,"taskId":vo.taskId,"actionType":"1"}) + await harmony_collectScore({ "appId": appId, "taskToken": shoppingActivityVos.taskToken, "taskId": vo.taskId, "actionType": "1" }) await $.wait(vo.waitDuration * 1000) } - await harmony_collectScore({"appId":appId,"taskToken":shoppingActivityVos.taskToken,"taskId":vo.taskId,"actionType":"0"}) - if ($.complete) break; + await harmony_collectScore({ "appId": appId, "taskToken": shoppingActivityVos.taskToken, "taskId": vo.taskId, "actionType": "0" }) } } } else if (vo.taskType === 14) { @@ -234,7 +254,7 @@ function harmony_collectScore(body = {}, taskType = '') { if (data && data.data && data.data.bizCode === 0) { if (taskType === 13) { console.log(`签到成功:获得${data.data.result.score}金币\n`) - } else if (body.taskId == 6) { + } else if (body.taskId == 5) { console.log(`助力成功:您的好友获得${data.data.result.score}金币\n`) } else { console.log(`完成任务:获得${data.data.result.score}金币\n`) @@ -242,13 +262,12 @@ function harmony_collectScore(body = {}, taskType = '') { } else { if (taskType === 13) { console.log(`签到失败:${data.data.bizMsg}\n`) - } else if (body.taskId == 6) { + } else if (body.taskId == 5) { console.log(`助力失败:${data.data.bizMsg || data.msg}\n`) if (data.code === -30001 || (data.data && data.data.bizCode === 108)) $.canHelp = false if (data.data.bizCode === 103) $.delcode = true } else { console.log(body.actionType === "0" ? `完成任务失败:${data.data.bizMsg}\n` : data.data.bizMsg) - if (data.data.bizMsg === "任务已完成") $.complete = true; } } } @@ -261,6 +280,7 @@ function harmony_collectScore(body = {}, taskType = '') { }) }) } + function interact_template_getLotteryResult() { return new Promise(resolve => { $.post(taskUrl('interact_template_getLotteryResult', {"appId":appId}), (err, resp, data) => { @@ -416,4 +436,4 @@ function jsonParse(str) { } } // prettier-ignore -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.data[t]||null}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){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=(()=>{})){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)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)})):this.isQuanX()?(this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t))):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{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){this.logErr(t)}}).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)}))}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,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t));else if(this.isNode()){this.initGotEnv(t);const{url:s,...i}=t;this.got.post(s,i).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)})}}time(t,e=null){const s=e?new Date(e):new Date;let i={"M+":s.getMonth()+1,"d+":s.getDate(),"H+":s.getHours(),"m+":s.getMinutes(),"s+":s.getSeconds(),"q+":Math.floor((s.getMonth()+3)/3),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)));return t}msg(e=t,s="",i="",r){const o=t=>{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()){let e=t.openUrl||t.url||t["open-url"],s=t.mediaUrl||t["media-url"];return{openUrl:e,mediaUrl:s}}if(this.isQuanX()){let e=t["open-url"]||t.url||t.openUrl,s=t["media-url"]||t.mediaUrl;return{"open-url":e,"media-url":s}}if(this.isSurge()){let e=t.url||t.openUrl||t["open-url"];return{url: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){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){t.length>0&&(this.logs=[...this.logs,...t]),console.log(t.join(this.logSeparator))}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){return new Promise(e=>setTimeout(e,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)}}(t,e)} \ No newline at end of file +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.data[t]||null}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){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=(()=>{})){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)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)})):this.isQuanX()?(this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t))):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{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){this.logErr(t)}}).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)}))}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,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t));else if(this.isNode()){this.initGotEnv(t);const{url:s,...i}=t;this.got.post(s,i).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)})}}time(t,e=null){const s=e?new Date(e):new Date;let i={"M+":s.getMonth()+1,"d+":s.getDate(),"H+":s.getHours(),"m+":s.getMinutes(),"s+":s.getSeconds(),"q+":Math.floor((s.getMonth()+3)/3),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)));return t}msg(e=t,s="",i="",r){const o=t=>{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()){let e=t.openUrl||t.url||t["open-url"],s=t.mediaUrl||t["media-url"];return{openUrl:e,mediaUrl:s}}if(this.isQuanX()){let e=t["open-url"]||t.url||t.openUrl,s=t["media-url"]||t.mediaUrl;return{"open-url":e,"media-url":s}}if(this.isSurge()){let e=t.url||t.openUrl||t["open-url"];return{url: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){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){t.length>0&&(this.logs=[...this.logs,...t]),console.log(t.join(this.logSeparator))}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){return new Promise(e=>setTimeout(e,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)}}(t,e)}