diff --git a/daily/gyjj.js b/daily/gyjj.js new file mode 100644 index 0000000..346ad87 --- /dev/null +++ b/daily/gyjj.js @@ -0,0 +1,131 @@ + + +/* +------------------------------------------ +@Author: sm +@Date: 2024.06.07 19:15 +@Description: 国乐酱酒小程序 +cron: 30 9 * * * +------------------------------------------ +#Notice: +变量名:gyjj +国乐酱酒小程序签到,使用前请先获取token,方法如下: +打开微信,进入国乐酱酒小程序,点击右下角“我的”, +打开抓包软件抓取https://member.guoyuejiu.com/api/sign/daily/sign 请求头的Authorization +抓取到的Authorization值即为token +⚠️【免责声明】 +------------------------------------------ +1、此脚本仅用于学习研究,不保证其合法性、准确性、有效性,请根据情况自行判断,本人对此不承担任何保证责任。 +2、由于此脚本仅用于学习研究,您必须在下载后 24 小时内将所有内容从您的计算机或手机或任何存储设备中完全删除,若违反规定引起任何事件本人对此均不负责。 +3、请勿将此脚本用于任何商业或非法目的,若违反规定请自行对此负责。 +4、此脚本涉及应用与本人无关,本人对因此引起的任何隐私泄漏或其他后果不承担任何责任。 +5、本人对任何脚本引发的问题概不负责,包括但不限于由脚本错误引起的任何损失和损害。 +6、如果任何单位或个人认为此脚本可能涉嫌侵犯其权利,应及时通知并提供身份证明,所有权证明,我们将在收到认证文件确认后删除此脚本。 +7、所有直接或间接使用、查看此脚本的人均应该仔细阅读此声明。本人保留随时更改或补充此声明的权利。一旦您使用或复制了此脚本,即视为您已接受此免责声明。 +*/ + +const { Env } = require("./tools/env") +const $ = new Env("国乐酱酒"); +let ckName = `gyjj`; +const strSplitor = "#"; +const axios = require("axios"); +const defaultUserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 16_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.31(0x18001e31) NetType/WIFI Language/zh_CN miniProgram" + + +class Task { + constructor(env) { + this.index = $.userIdx++ + this.user = env.split(strSplitor); + this.token = this.user[0]; + + } + + async run() { + + await this.sign() + await this.account() + } + + async sign() { + try { + + let options = { + method: 'get', + url: `https://member.guoyuejiu.com/api/sign/daily/sign`, + headers: { + "Authorization": this.token, + "User-Agent": 'Mozilla/5.0 (iPhone; CPU iPhone OS 16_7_15 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.70(0x1800462d) NetType/WIFI Language/zh_CN', + "Referer": "https://servicewechat.com/wxeff120e4d11594c0/85/page-frame.html" + }, + + } + let { data: result } = await axios.request(options) + if (result?.code == 0) { + //打印签到结果 + $.log(`🕊账号[${this.index}] 签到成功:签到[${result.data.spanSumDays}]天🎉`); + this.mist = result.data.spanSumDays + } else { + $.log(`🕊账号[${this.index}] 签到失败:${result.message}⛔`) + } + } catch (e) { + console.log(e); + } + } + + // + async account() { + try { + let options = { + method: 'get', + url: `https://member.guoyuejiu.com/api/user/info`, + headers: { + "Authorization": this.token, + "User-Agent": 'Mozilla/5.0 (iPhone; CPU iPhone OS 16_7_15 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.70(0x1800462d) NetType/WIFI Language/zh_CN', + "Referer": "https://servicewechat.com/wxeff120e4d11594c0/85/page-frame.html" + } + + + } + let { data: result } = await axios.request(options) + if (result?.code == 0) { + //打印签到结果 + $.log(`🕊账号[${this.index}] 查询成功:总积分[${result.data.score}]🎉`); + + } else { + $.log(`🕊账号[${this.index}] 查询失败:${result.message}🚫`) + } + } catch (e) { + console.log(e); + } + } + + + + + + + +} + +!(async () => { + await getNotice() + $.checkEnv(ckName); + + for (let user of $.userList) { + await new Task(user).run(); + } +})() + .catch((e) => console.log(e)) + .finally(() => $.done()); + +async function getNotice() { + let options = { + url: `https://ghproxy.net/https://raw.githubusercontent.com/smallfawn/Note/refs/heads/main/Notice.json`, + headers: { + "User-Agent": defaultUserAgent, + } + } + let { data: res } = await axios.request(options); + $.log(res) + return res +} \ No newline at end of file diff --git a/gjzp.js b/gjzp.js deleted file mode 100644 index 1ce40d4..0000000 --- a/gjzp.js +++ /dev/null @@ -1,424 +0,0 @@ -/** - * 工匠职聘 - * cron 52 8 * * * gjzp.js - * - * 22/12/10 每日签到 赚工分 - * 22/12/11 每日红包奖励 判定CK是否有效 - * 23/01/23 删除抽奖,修复BUG - * ========= 青龙--配置文件 =========== - * # 项目名称 - * export gjzp_data='authorization&android' - * - * 多账号用 @ 分割 - * 抓包 api-recruitment.yzw.cn , 找到 headers中 authorization 即可 - * 如果你是ios端请在authorization后加上ios如果是android请输入android 必须小写 - * 首次使用请 去本APP => 我的 => 横幅 > 工分夺宝处首抽一次(绑定你的微信小程序) 否则不绑定抽不了奖 - * 如果是先注册小程序后再去APP,就无需绑定了 直接抓CK即可 - * ==================================== - * - */ - - - -const $ = new Env("工匠职聘"); -const ckName = "gjzp_data"; -//-------------------- 一般不动变量区域 ------------------------------------- -const Notify = 1; //0为关闭通知,1为打开通知,默认为1 -let debug = 1; //Debug调试 0关闭 1开启 -let envSplitor = ["@", "\n"]; //多账号分隔符 -let ck = msg = ''; //let ck,msg -let host, hostname; -let userCookie = ($.isNode() ? process.env[ckName] : $.getdata(ckName)) || ''; -let userList = []; -let userIdx = 0; -let userCount = 0; -//---------------------- 自定义变量区域 ----------------------------------- -//--------------------------------------------------------- - -async function start() { - console.log('\n================== 用户查询 ==================\n'); - taskall = []; - for (let user of userList) { - taskall.push(await user.user_info(1)); - await $.wait(3000); //延迟 - } - await Promise.all(taskall); - console.log('\n================== 红包签到 ==================\n'); - taskall = []; - for (let user of userList) { - await user.task_sign('红包签到') - await $.wait(3000); //延迟 - } - await Promise.all(taskall); - console.log('\n================== 日常任务 ==================\n'); - taskall = []; - for (let user of userList) { - await user.task_see(); - await $.wait(3000); //延迟 - } - await Promise.all(taskall); - - - -} - - -class UserInfo { - constructor(str) { - this.index = ++userIdx; - this.cktest = str.split('&')[0]; //单账号多变量分隔符 - //this.deviceid = str.split('&')[1]; //单账号多变量分隔符 - this.ck = "Bearer " + this.cktest.replace('Bearer', '') - this.PhoneType = str.split('&')[1]; - //let ck = str.split('&') - //this.data1 = ck[0] - //this.host = "echo.apipost.cn"; - //this.hostname = "https://" + this.host; - } - - async user_info(type) { // userinfo - try { - let options = { - method: 'POST', - url: 'https://api-recruitment.yzw.cn/v2/labor/app/user/getUserBaseInfo', - headers: { - Host: 'api-recruitment.yzw.cn', - accept: 'application/json, text/plain, */*', - version: '2.14.0', - authorization: this.ck, - appsourcetype: '1', - //'x-device-id': this.deviceid, - //'x-flow-num': 'f4a3d43f-50c8-4d50-9287-834894e86339', - //'x-device': 'zhipin/android/29/2.14.0/392.72727272727275/829.0909090909091/2.75', - 'content-type': 'application/json', - //'content-length': '11', - //'accept-encoding': 'gzip', - //cookie: 'acw_tc=2f624a4016706498913978918e4b42d68638eccb6145bcc0a89b50a20dab88', - //'user-agent': 'okhttp/4.9.2' - }, - body: {}, - json: true - }; - options = changeCode(options) - //console.log(options); - let result = await httpRequest(options); - //console.log(result); - if (type == 1) { - if (result.code == 20000) { - DoubleLog(`账号[${this.index}] 账号: [${result.data.userId}] 昵称[${result.data.name}] 工分余额[${result.data.totalScore}]`); - //let userId = result.data.userId - //return userId - } else if (result.code == 40005) { - DoubleLog(`账号[${this.index}] 用户信息查询:失败 ❌ 了呢,原因${result.message}`);//没次数 - console.log(result); - } else { - DoubleLog(`账号[${this.index}] 用户信息查询:失败 ❌ 了呢,原因未知`); - console.log(result); - } - } else if (type == 0) { - if (result.code == 20000) { - let userId = result.data.userId - return userId - } else if (result.code == 40005) { - console.log(result); - } else { - } - } - } catch (error) { - console.log(error); - } - } - async task2() { // task2 红包任务列表 - try { - let options = { - method: 'GET', - url: 'https://api-recruitment.yzw.cn/v2/labor/app/sign/tasks', - headers: { - Host: 'api-recruitment.yzw.cn', - accept: 'application/json, text/plain, */*', - version: '2.14.0', - authorization: this.ck, - appsourcetype: '1', - //'x-device-id': this.deviceid, - //'x-flow-num': 'f4a3d43f-50c8-4d50-9287-834894e86339', - //'x-device': 'zhipin/android/29/2.14.0/392.72727272727275/829.0909090909091/2.75', - //'accept-encoding': 'gzip', - //cookie: 'acw_tc=2f624a4016706498913978918e4b42d68638eccb6145bcc0a89b50a20dab88', - //'user-agent': 'okhttp/4.9.2' - } - }; - options = changeCode(options) - //console.log(options); - let result = await httpRequest(options); - //console.log(result); - if (result.code == 20000) { - //DoubleLog(`账号[${this.index}] 账号: [${result.data.userId}] 昵称[${result.data.name}] 工分余额[${result.data.totalScore}]`); - } else if (result.code == 40005) { - //DoubleLog(`账号[${this.index}] 用户信息查询:失败 ❌ 了呢,原因${result.message}`);//没次数 - //console.log(result); - } else { - //DoubleLog(`账号[${this.index}] 用户信息查询:失败 ❌ 了呢,原因未知`); - //console.log(result); - } - return result - } catch (error) { - console.log(error); - } - } - - async task_sign() { // 红包签到 - //console.log(this.cktest.replace('Bearer', '')) - try { - let options = { - method: 'GET', - url: 'https://api-recruitment.yzw.cn/v2/labor/app/sign/sign', - headers: { - Host: 'api-recruitment.yzw.cn', - accept: 'application/json, text/plain, */*', - version: '2.14.0', - authorization: this.ck, - appsourcetype: '1', - //'x-device-id': this.deviceid, - //'x-flow-num': '71abe6e4-2a7f-4c5a-89db-81a002139135', - //'x-device': 'zhipin/android/29/2.14.0/392.72727272727275/829.0909090909091/2.75', - //cookie: 'acw_tc=2f624a2e16706248652012563e316a3fc1bfc16d803e478a49dfb0ce7727bd', - //'user-agent': 'okhttp/4.9.2', - //'if-modified-since': 'Fri, 09 Dec 2022 05:21:36 GMT' - } - }; - options = changeCode(options) - //console.log(options); - let result = await httpRequest(options); - //console.log(result); - if (result.code == 20000) { - DoubleLog(`账号[${this.index}] 签到成功获得: ${result.message}`); - } else if (result.code == 40005) { - DoubleLog(`账号[${this.index}] 签到:失败 ❌ 了呢,原因${result.message}!`); - } else { - console.log(result) - } - } catch (error) { - console.log(error); - } - } - - async task_see() { - let t2 = await this.task2() - if (t2.code == 20000) { - for (let o in t2.data) { - let id = await this.user_info(0) - if (t2.data[o].id == "13" && t2.data[o].status == 0) { - await this.task_see3() - await $.wait(10000) - } else if (t2.data[o].id == "13" && t2.data[o].status == 1) { - console.log(`账号[${this.index}]任务红包浏览首页完成`); - } - if (t2.data[o].id == "18" && t2.data[o].status == 0) { - //console.log(t2.data[o]); - for (let i = 0; i < 2; i++) { - await this.task_see4(id) - await $.wait(10000) - } - } else if (t2.data[o].id == "18" && t2.data[o].status == 1) { - //await this.task_see4("红包分享职位",id) - console.log(`账号[${this.index}]任务红包分享职位完成`); - } - } - } - } - - async task_see3() { //红包任务 浏览首页 - try { - let options = { - method: 'POST', - url: 'https://api-recruitment.yzw.cn/v2/labor/app/browseCollectRecord/add', - headers: { - Host: 'api-recruitment.yzw.cn', - accept: 'application/json, text/plain, */*', - version: '2.14.0', - authorization: this.ck, - appsourcetype: '1', - //'x-device-id': 'd310c38476e58308d310c38476e58308d310c38476e58308d310c38476e58308', - //'x-flow-num': 'd019070d-f032-4ffc-9737-188c477cb2ee', - //'x-device': 'zhipin/android/29/2.14.0/392.72727272727275/829.0909090909091/2.75', - 'content-type': 'application/json', - 'user-agent': 'okhttp/4.9.2' - }, - body: { type: 1, recordType: 7 }, - json: true - }; - options = changeCode(options) - //console.log(options); - let result = await httpRequest(options); - //console.log(result); - if (result.code == 20000) { - DoubleLog(`账号[${this.index}] 红包任务浏览首页成功${result.data}`); - console.log('本次可能获得0.05'); - } else if (result.code == 40005) { - DoubleLog(`账号[${this.index}] 红包任务浏览首页:失败 ❌ 了呢,原因${result.message}`); - //console.log(result); - } else { - DoubleLog(`账号[${this.index}] 红包任务浏览首页:失败 ❌ 了呢,原因未知`); - console.log(result); - } - } catch (error) { - console.log(error); - } - } - - async task_see4(userId) { // 红包任务 分享职业卡片 - try { - let options = { - method: 'POST', - url: 'https://api-recruitment.yzw.cn/v2/labor/app/userShareRecord/add', - headers: { - Host: 'api-recruitment.yzw.cn', - accept: 'application/json, text/plain, */*', - version: '2.14.0', - authorization: this.ck, - appsourcetype: '1', - 'content-type': 'application/json' - }, - body: { shareTarget: 0, userId: userId, shareType: 1, shareOtherId: 44207 }, - json: true - }; - options = changeCode(options) - //console.log(options); - let result = await httpRequest(options); - //console.log(result); - if (result.code == 20000) { - DoubleLog(`账号[${this.index}] 红包任务 分享职位 成功${result.data}`); - console.log('本次可能获得0.02'); - } else if (result.code == 40005) { - DoubleLog(`账号[${this.index}] 红包任务 分享职位:失败 ❌ 了呢,原因${result.message}`); - //console.log(result); - } else { - DoubleLog(`账号[${this.index}] 红包任务 分享职位:失败 ❌ 了呢,原因未知`); - console.log(result); - } - } catch (error) { - console.log(error); - } - } - - -} - -!(async () => { - if (!(await checkEnv())) return; - if (userList.length > 0) { - await start(); - } - await SendMsg(msg); -})() - .catch((e) => console.log(e)) - .finally(() => $.done()); - - -//******************************************************** -// 变量检查与处理 -async function checkEnv() { - if (userCookie) { - // console.log(userCookie); - let e = envSplitor[0]; - for (let o of envSplitor) - if (userCookie.indexOf(o) > -1) { - e = o; - break; - } - for (let n of userCookie.split(e)) n && userList.push(new UserInfo(n)); - userCount = userList.length; - } else { - console.log("未找到CK"); - return; - } - return console.log(`共找到${userCount}个账号`), true;//true == !0 -} -///////////////////////////////////////////////////////////////////////////////////// -function changeCode(oldoptions) { - let newoptions = new Object(), - urlTypeArr = ['qs', 'params'], - bodyTypeArr = ['body', 'data', 'form', 'formData'] - for (let e in urlTypeArr) { - urlTypeArr[e] in oldoptions ? newoptions.url = changeUrl(urlTypeArr[e]) : newoptions.url = oldoptions.url - } - 'content-type' in oldoptions.headers ? newoptions.headers = changeHeaders(oldoptions.headers) : newoptions.headers = oldoptions.headers - function changeUrl(type) { - url = oldoptions.url + '?' - for (let key in oldoptions[type]) { url += key + '=' + oldoptions[type][key] + '&' } - url = url.substring(0, url.length - 1) - return url - } - function changeHeaders(headers) { - let tmp = headers['content-type'] - delete headers['content-type'] - headers['Content-Type'] = tmp - return headers - } - for (let o in bodyTypeArr) { - if (bodyTypeArr[o] in oldoptions) { - (Object.prototype.toString.call(oldoptions[bodyTypeArr[o]]) === '[object Object]') ? newoptions.body = JSON.stringify(oldoptions[bodyTypeArr[o]]) : newoptions.body = oldoptions[bodyTypeArr[o]] - } - } - return newoptions -} -function httpRequest(options, method) { - //options = changeCode(options) - typeof (method) === 'undefined' ? ('body' in options ? method = 'post' : method = 'get') : method = method - return new Promise((resolve) => { - $[method](options, (err, resp, data) => { - try { - if (err) { - console.log(`${method}请求失败`); - //console.log(JSON.parse(err)); - $.logErr(err); - //throw new Error(err); - //console.log(err); - } else { - //httpResult = data; - //httpResponse = resp; - if (data) { - //console.log(data); - data = JSON.parse(data); - resolve(data) - } else { - console.log(`请求api返回数据为空,请检查自身原因`) - } - } - } catch (e) { - //console.log(e, resp); - $.logErr(e, resp); - } finally { - resolve(); - } - }) - }) -} -// 双平台log输出 -function DoubleLog(data) { - if ($.isNode()) { - if (data) { - console.log(`${data}`); - msg += `\n${data}` - } - } else { - console.log(`${data}`); - msg += `\n${data}` - } -} -// 发送消息 -async function SendMsg(message) { - if (!message) return; - if (Notify > 0) { - if ($.isNode()) { - var notify = require("./sendNotify"); - await notify.sendNotify($.name, message) - } else { - $.msg($.name, '', message) - } - } else { - console.log(message) - } -} -// 完整 Env -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/gujinggongjiu.js b/gujinggongjiu.js deleted file mode 100644 index a9b9bd9..0000000 --- a/gujinggongjiu.js +++ /dev/null @@ -1,152 +0,0 @@ -/* ------------------------------------------- -@Date: 2024.08.01 -@Description: 古井贡酒会员中心小程序 ------------------------------------------- -变量名 gujing -[Script] -http-response - -[MITM] -hostname = - - -const $ = new Env("古井贡酒会员中心小程序"); -let ckName = `gujing`; -let userCookie = checkEnv( - ($.isNode() ? process.env[ckName] : $.getdata(ckName)) || "" -); -const notify = $.isNode() ? require("./sendNotify") : ""; - -!(async () => { - console.log( - `==================================================\n 脚本执行 - 北京时间(UTC+8): ${new Date( - new Date().getTime() + - new Date().getTimezoneOffset() * 60 * 1000 + - 8 * 60 * 60 * 1000 - ).toLocaleString()} \n==================================================` - ); - //console.log(userCookie) - if (!userCookie?.length) return console.log(`没有找到CK哦`); - let index = 1; - let strSplitor = "#"; - - for (let user of userCookie) { - $.log(`\n🚀 user:【${index}】 start work\n`); - index++ - $.token = user - $.ckStatus = true; - await search() - } - - await $.sendMsg($.logs.join("\n")); -})() - .catch((e) => console.log(e)) - .finally(() => $.done()); -async function search() { - let data = JSON.stringify({ - "activityId": "110001000", - "preview": false - }); - - let config = { - method: 'POST', - url: 'https://scrm.gujing.com/gujing_scrm/wxclient/mkt/activities/sign:search', - headers: { - 'User-Agent': 'Mozilla/5.0 (Linux; Android 10; MI 8 Lite Build/QKQ1.190910.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/122.0.6261.120 Mobile Safari/537.36 XWEB/1220089 MMWEBSDK/20240404 MMWEBID/8150 MicroMessenger/8.0.49.2600(0x28003156) WeChat/arm64 Weixin NetType/WIFI Language/zh_CN ABI/arm64 miniProgram/wxba9855bdb1a45c8e', - 'Accept': 'application/json, text/plain, */*', - 'sec-ch-ua': '"Chromium";v="122", "Not(A:Brand";v="24", "Android WebView";v="122"', - 'Content-Type': 'application/json;charset=UTF-8', - 'sec-ch-ua-mobile': '?1', - 'Access-Token': $.token, - 'sec-ch-ua-platform': '"Android"', - 'Origin': 'https://scrm.gujing.com', - 'X-Requested-With': 'com.tencent.mm', - 'Sec-Fetch-Site': 'same-origin', - 'Sec-Fetch-Mode': 'cors', - 'Sec-Fetch-Dest': 'empty', - 'Accept-Language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7', - - }, - data: data - }; - let { data: result } = await Request(config) - if (result?.code == 200) { - if (result.content.signed !== 1) { - $.log(`未签到 ===> 签到ing`) - await signIn() - } else { - $.log(`已签到 ===> 什么都不做`) - } - } else { - $.log(`签到查询失败 [${JSON.stringify(result)}]`) - } -} -async function signIn() { - let data = JSON.stringify({ - "activityId": "110001000", - "preview": false - }); - - let config = { - method: 'POST', - url: 'https://scrm.gujing.com/gujing_scrm/wxclient/mkt/activities/sign:search', - headers: { - 'User-Agent': 'Mozilla/5.0 (Linux; Android 10; MI 8 Lite Build/QKQ1.190910.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/122.0.6261.120 Mobile Safari/537.36 XWEB/1220089 MMWEBSDK/20240404 MMWEBID/8150 MicroMessenger/8.0.49.2600(0x28003156) WeChat/arm64 Weixin NetType/WIFI Language/zh_CN ABI/arm64 miniProgram/wxba9855bdb1a45c8e', - 'Accept': 'application/json, text/plain, */*', - 'sec-ch-ua': '"Chromium";v="122", "Not(A:Brand";v="24", "Android WebView";v="122"', - 'Content-Type': 'application/json;charset=UTF-8', - 'sec-ch-ua-mobile': '?1', - 'Access-Token': $.token, - 'sec-ch-ua-platform': '"Android"', - 'Origin': 'https://scrm.gujing.com', - 'X-Requested-With': 'com.tencent.mm', - 'Sec-Fetch-Site': 'same-origin', - 'Sec-Fetch-Mode': 'cors', - 'Sec-Fetch-Dest': 'empty', - 'Accept-Language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7', - }, - data: data - }; - let { data: result } = await Request(config) - if (result?.code == 200) { - $.log(`签到成功 获得积分[${result.content.point}]`) - } else { - $.log(`签到失败 [${result.chnDesc}]`) - } -} - -function checkEnv(userCookie) { - const envSplitor = ["&", "\n"]; - //console.log(userCookie); - let userList = userCookie - .split(envSplitor.find((o) => userCookie.includes(o)) || "&") - .filter((n) => n); - console.log(`共找到${userList.length}个账号`); - return userList; -} -// prettier-ignore -function Env(t, s) { return new (class { constructor(t, s) { this.name = t; this.logs = []; this.logSeparator = "\n"; this.startTime = new Date().getTime(); Object.assign(this, s); this.log("", `\ud83d\udd14${this.name},\u5f00\u59cb!`) } isNode() { return "undefined" != typeof module && !!module.exports } isQuanX() { return "undefined" != typeof $task } queryStr(options) { return Object.entries(options).map(([key, value]) => `${key}=${typeof value === "object" ? JSON.stringify(value) : value}`).join("&") } getURLParams(url) { const params = {}; const queryString = url.split("?")[1]; if (queryString) { const paramPairs = queryString.split("&"); paramPairs.forEach((pair) => { const [key, value] = pair.split("="); params[key] = value }) } return params } isJSONString(str) { try { return JSON.parse(str) && typeof JSON.parse(str) === "object" } catch (e) { return false } } isJson(obj) { var isjson = typeof obj == "object" && Object.prototype.toString.call(obj).toLowerCase() == "[object object]" && !obj.length; return isjson } async sendMsg(message) { if (!message) return; if (this.isNode()) { await notify.sendNotify(this.name, message) } else { this.msg(this.name, "", message) } } randomNumber(length) { const characters = "0123456789"; return Array.from({ length }, () => characters[Math.floor(Math.random() * characters.length)]).join("") } randomString(length) { const characters = "abcdefghijklmnopqrstuvwxyz0123456789"; return Array.from({ length }, () => characters[Math.floor(Math.random() * characters.length)]).join("") } uuid() { return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) { var r = (Math.random() * 16) | 0, v = c == "x" ? r : (r & 0x3) | 0x8; return v.toString(16) }) } time(t) { let s = { "M+": new Date().getMonth() + 1, "d+": new Date().getDate(), "H+": new Date().getHours(), "m+": new Date().getMinutes(), "s+": new Date().getSeconds(), "q+": Math.floor((new Date().getMonth() + 3) / 3), S: new Date().getMilliseconds(), }; /(y+)/.test(t) && (t = t.replace(RegExp.$1, (new Date().getFullYear() + "").substr(4 - RegExp.$1.length))); for (let e in s) { new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? s[e] : ("00" + s[e]).substr(("" + s[e]).length))) } return t } msg(title = t, subtitle = "", body = "", options) { const formatOptions = (options) => { if (!options) { return options } else if (typeof options === "string") { if (this.isQuanX()) { return { "open-url": options } } else { return undefined } } else if (typeof options === "object" && (options["open-url"] || options["media-url"])) { if (this.isQuanX()) { return options } else { return undefined } } else { return undefined } }; if (!this.isMute) { if (this.isQuanX()) { $notify(title, subtitle, body, formatOptions(options)) } } let logs = ["", "==============📣系统通知📣=============="]; logs.push(title); subtitle ? logs.push(subtitle) : ""; body ? logs.push(body) : ""; console.log(logs.join("\n")); this.logs = this.logs.concat(logs) } log(...t) { t.length > 0 && (this.logs = [...this.logs, ...t]), console.log(t.join(this.logSeparator)) } logErr(t, s) { const e = !this.isQuanX(); e ? this.log("", `\u2757\ufe0f${this.name},\u9519\u8bef!`, t.stack) : this.log("", `\u2757\ufe0f${this.name},\u9519\u8bef!`, t) } wait(t) { return new Promise((s) => setTimeout(s, t)) } done(t = {}) { const s = new Date().getTime(), e = (s - this.startTime) / 1e3; this.log("", `\ud83d\udd14${this.name},\u7ed3\u675f!\ud83d\udd5b ${e}\u79d2`); this.log(); if (this.isNode()) { process.exit(1) } if (this.isQuanX()) { $done(t) } } })(t, s) } - -async function Request(options) { - if ($.isNode()) { - const axios = require("axios"); - Request = async (options) => { - try { - return await axios.request(options); - } catch (error) { - return error && error.error ? error.error : "请求失败"; - } - }; - } - if ($.isQuanX()) { - Request = async (options) => { - try { - return await $task.fetch(options); - } catch (error) { - return error && error.error ? error.error : "请求失败"; - } - }; - } - return await Request(options); -} diff --git a/guolejiangjiu.js b/guolejiangjiu.js deleted file mode 100644 index d040688..0000000 --- a/guolejiangjiu.js +++ /dev/null @@ -1,256 +0,0 @@ - -/** - * 国乐酱酒 签到得酒 - * Gljj - * cron "0 7 * * *" gljj.js - * export gljj= Authorization 多账号换行或者#分隔 - - - */ -// ============================================================================================================ -const $ = new Env('国乐酱酒') -const axios = require('axios') -const env_name = 'gljj' //环境变量名字 -const env = process.env[env_name] || '' -const Notify = 1 -const debug = 0 -let scriptVersionNow = "1.0.0"; -let msg = ""; -// ==================================异步顺序============================================================================== -!(async () => { - //await getNotice(); - //await getVersion("yang7758258/ohhh154@main/gljj.js"); - await main(); - await SendMsg(msg); - -})() - .catch((e) => $.logErr(e)) - .finally(() => $.done()); -//==================================脚本入口函数main()============================================================== - -async function main() { - if (env == '') { - //没有设置变量,直接退出 - console.log(`没有填写变量,请查看脚本说明: ${env_name}🚳`) - return - } - let user_ck = env.split('\n') - DoubleLog(`\n========= 共找到 ${user_ck.length} 个账号 =========`); - let index = 1 //用来给账号标记序号, 从1开始 - for (let ck of user_ck) { - if (!ck) continue //跳过空行 - let ck_info = ck.split('&') - let Authorization = ck_info[0] - //let unionid = ck_info[1] - //let deviceCode = ck_info[2] - let user = { - index: index, - Authorization, - //unionid, - //deviceCode, - } - index = index + 1 //每次用完序号+1 - //开始账号任务 - let Run = new run(user); - await Run.userTask(user) - //每个账号之间等1~5秒随机时间 - let rnd_time = Math.floor(Math.random() * 4000) + 1000 - console.log(`随机等待${rnd_time / 1000}秒...`) - await $.wait(rnd_time) - } -} -// ======================================开始任务========================================= -class run { - constructor(user) { - this.headers = { - "Authorization": user.Authorization, - "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 17_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.48(0x18003030) NetType/WIFI Language/zh_CN", - } - - } -async userTask(user) { - console.log(`\n========= 账号[${user.index}]开始任务 =========`) - await this.sign(user) - if (this.mist >= 7) { - DoubleLog(`账号[${user.index}] 签到天数大于等于7天,快去领酒🍺`); - } -} -// ============================================================================================================================= -// - async sign(user) { - try { - DoubleLog(`🕊账号[${user.index}] 开始签到任务...`); - - //console.log(formattedDate); - let urlObject = { - method: 'get', - url: `https://member.guoyuejiu.com/api/sign/daily/sign`, - headers: this.headers, - - } - //console.log(urlObject); - let { data: result} = await axios.request(urlObject) - //console.log(result); - if (result?.code == 0) { - //打印签到结果 - DoubleLog(`🕊账号[${user.index}] 签到成功:签到[${result.data.spanSumDays}]天🎉`); - this.mist = result.data.spanSumDays - }else{ - DoubleLog(`🕊账号[${user.index}] 签到失败:${result.message}⛔`) - } - } catch (e) { - console.log(e); - } - } - -// -async account(user) { - try { - DoubleLog(`🕊账号[${user.index}] 开始查询任务...`); - let urlObject = { - method: 'get', - url: `https://apiserver.chinagoods.com/growth/score/record/page?pageNo=1&pageSize=10&month=7&year=2024&userType=BUYER`, - headers: this.headers, - - } - //console.log(urlObject); - let { data: result} = await axios.request(urlObject) - //console.log(result); - if (result?.code == '20000') { - //打印签到结果 - DoubleLog(`🕊账号[${user.index}] 查询成功:总积分[${result.data.current}]🎉`); - - }else { - DoubleLog(`🕊账号[${user.index}] 查询失败:${result.msg}🚫`) - } - } catch (e) { - console.log(e); - } - } - -} -/** - * =========================================================发送消息============================================= - */ -async function SendMsg(message) { - if (!message) return; - if (Notify > 0) { - if ($.isNode()) { - var notify = require("./sendNotify"); - await notify.sendNotify($.name, message); - } else { - // $.msg(message); - $.msg($.name, '', message) - } - } else { - console.log(message); - } -} -/** - * =====================================================双平台log输出========================================== - */ -function DoubleLog(data) { - if ($.isNode()) { - if (data) { - console.log(`${data}`); - msg += `\n${data}`; - } - } else { - console.log(`${data}`); - msg += `\n${data}`; - } - -} -/** -* ======================================================等待 X 秒============================================ -*/ -function wait(n) { - return new Promise(function (resolve) { - setTimeout(resolve, n * 1000); - }); -} -/** -* ======================================================随机等待 1-5 秒============================================ -*/ -function sjwait() { - return new Promise(function (resolve) { - let waitTime = Math.floor(Math.random() * 4000 + 1000); - setTimeout(resolve, waitTime); - }); -} -// ==========================================================13位时间戳===================================================== -function getTimestamp() { - return new Date().getTime(); -} -//===============================================网络请求httpRequest========================================= -function httpRequest(options, timeout = 1 * 1000) { - method = options.method ? options.method.toLowerCase() : options.body ? "post" : "get"; - return new Promise(resolve => { - setTimeout(() => { - $[method](options, (err, resp, data) => { - try { - if (err) { - console.log(JSON.stringify(err)); - $.logErr(err); - } else { - try { data = JSON.parse(data); } catch (error) { } - } - } catch (e) { - console.log(e); - $.logErr(e, resp); - } finally { - resolve(data); - } - }) - }, timeout) - }) -} -//==============================================Debug模式=============================================== -function debugLog(...args) { - if (debug) { - console.log(...args); - } -} -//===============================================获取远程通知======================================== -async function getNotice() { - try { - const urls = [ - "https://main/tl.json", - - ]; - let notice = null; - for (const url of urls) { - const options = { url, headers: { "User-Agent": "" }, }; - const result = await httpRequest(options); - if (result && "notice" in result) { - notice = result.notice.replace(/\\n/g, "\n"); - break; - } - } - if (notice) { $.DoubleLog(notice); } - } catch (e) { - console.log(e); - } -} -//==============================================获取远程版本================================================= -function getVersion(scriptUrl, timeout = 3 * 1000) { - return new Promise((resolve) => { - const options = { url: `https://fastly.jsdelivr.net/gh/${scriptUrl}` }; - $.get(options, (err, resp, data) => { - try { - const regex = /scriptVersionNow\s*=\s*(["'`])([\d.]+)\1/; - const match = data.match(regex); - const scriptVersionLatest = match ? match[2] : ""; - DoubleLog(`\n当前版本:[${scriptVersionNow}]>>>>>云端☁️版本:[${scriptVersionLatest}]`); - } catch (e) { - $.logErr(e, resp); - } - resolve(); - }, timeout); - }); -} - -//=============================================================================================================================================== -//================================================固定API=============================================================================================== -function Env(t, e) { 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, a) => { s.call(this, t, (t, s, r) => { t ? a(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.userList = []; this.userIdx = 0; (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.encoding = "utf-8"), (this.startTime = new Date().getTime()), Object.assign(this, e), this.log("", `🔔${this.name},开始!`) } getEnv() { return "undefined" != typeof $environment && $environment["surge-version"] ? "Surge" : "undefined" != typeof $environment && $environment["stash-version"] ? "Stash" : "undefined" != typeof module && module.exports ? "Node.js" : "undefined" != typeof $task ? "Quantumult X" : "undefined" != typeof $loon ? "Loon" : "undefined" != typeof $rocket ? "Shadowrocket" : void 0 } isNode() { return "Node.js" === this.getEnv() } isQuanX() { return "Quantumult X" === this.getEnv() } isSurge() { return "Surge" === this.getEnv() } isLoon() { return "Loon" === this.getEnv() } isShadowrocket() { return "Shadowrocket" === this.getEnv() } isStash() { return "Stash" === this.getEnv() } 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 a = this.getdata(t); if (a) 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, a) => e(a)) }) } runScript(t, e) { return new Promise((s) => { let a = this.getdata("@chavy_boxjs_userCfgs.httpapi"); a = a ? a.replace(/\n/g, "").trim() : a; let r = this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout"); (r = r ? 1 * r : 20), (r = e && e.timeout ? e.timeout : r); const [i, o] = a.split("@"), n = { url: `http://${o}/v1/scripting/evaluate`, body: { script_text: t, mock_type: "cron", timeout: r }, headers: { "X-Key": i, Accept: "*/*" }, timeout: r, }; this.post(n, (t, e, a) => s(a)) }).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), a = !s && this.fs.existsSync(e); if (!s && !a) return {}; { const a = s ? t : e; try { return JSON.parse(this.fs.readFileSync(a)) } 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), a = !s && this.fs.existsSync(e), r = JSON.stringify(this.data); s ? this.fs.writeFileSync(t, r) : a ? this.fs.writeFileSync(e, r) : this.fs.writeFileSync(t, r) } } lodash_get(t, e, s) { const a = e.replace(/\[(\d+)\]/g, ".$1").split("."); let r = t; for (const t of a) 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, a) => Object(t[s]) === t[s] ? t[s] : (t[s] = Math.abs(e[a + 1]) >> 0 == +e[a + 1] ? [] : {}), t)[e[e.length - 1]] = s), t) } getdata(t) { let e = this.getval(t); if (/^@/.test(t)) { const [, s, a] = /^@(.*?)\.(.*?)$/.exec(t), r = s ? this.getval(s) : ""; if (r) try { const t = JSON.parse(r); e = t ? this.lodash_get(t, a, "") : e } catch (t) { e = "" } } return e } setdata(t, e) { let s = !1; if (/^@/.test(e)) { const [, a, r] = /^@(.*?)\.(.*?)$/.exec(e), i = this.getval(a), o = a ? ("null" === i ? null : i || "{}") : "{}"; try { const e = JSON.parse(o); this.lodash_set(e, r, t), (s = this.setval(JSON.stringify(e), a)) } catch (e) { const i = {}; this.lodash_set(i, r, t), (s = this.setval(JSON.stringify(i), a)) } } else s = this.setval(t, e); return s } getval(t) { switch (this.getEnv()) { case "Surge": case "Loon": case "Stash": case "Shadowrocket": return $persistentStore.read(t); case "Quantumult X": return $prefs.valueForKey(t); case "Node.js": return (this.data = this.loaddata()), this.data[t]; default: return (this.data && this.data[t]) || null } } setval(t, e) { switch (this.getEnv()) { case "Surge": case "Loon": case "Stash": case "Shadowrocket": return $persistentStore.write(t, e); case "Quantumult X": return $prefs.setValueForKey(t, e); case "Node.js": return ((this.data = this.loaddata()), (this.data[e] = t), this.writedata(), !0); default: return (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 = () => { }) { switch ((t.headers && (delete t.headers["Content-Type"], delete t.headers["Content-Length"], delete t.headers["content-type"], delete t.headers["content-length"]), this.getEnv())) { case "Surge": case "Loon": case "Stash": case "Shadowrocket": default: this.isSurge() && this.isNeedRewrite && ((t.headers = t.headers || {}), Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.get(t, (t, s, a) => { !t && s && ((s.body = a), (s.statusCode = s.status ? s.status : s.statusCode), (s.status = s.statusCode)), e(t, s, a) }); break; case "Quantumult X": this.isNeedRewrite && ((t.opts = t.opts || {}), Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then((t) => { const { statusCode: s, statusCode: a, headers: r, body: i, bodyBytes: o, } = t; e(null, { status: s, statusCode: a, headers: r, body: i, bodyBytes: o, }, i, o) }, (t) => e((t && t.error) || "UndefinedError")); break; case "Node.js": let s = require("iconv-lite"); 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: a, statusCode: r, headers: i, rawBody: o, } = t, n = s.decode(o, this.encoding); e(null, { status: a, statusCode: r, headers: i, rawBody: o, body: n, }, n) }, (t) => { const { message: a, response: r } = t; e(a, r, r && s.decode(r.rawBody, this.encoding)) }) } } post(t, e = () => { }) { const s = t.method ? t.method.toLocaleLowerCase() : "post"; switch ((t.body && t.headers && !t.headers["Content-Type"] && !t.headers["content-type"] && (t.headers["content-type"] = "application/x-www-form-urlencoded"), t.headers && (delete t.headers["Content-Length"], delete t.headers["content-length"]), this.getEnv())) { case "Surge": case "Loon": case "Stash": case "Shadowrocket": default: this.isSurge() && this.isNeedRewrite && ((t.headers = t.headers || {}), Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient[s](t, (t, s, a) => { !t && s && ((s.body = a), (s.statusCode = s.status ? s.status : s.statusCode), (s.status = s.statusCode)), e(t, s, a) }); break; case "Quantumult X": (t.method = s), this.isNeedRewrite && ((t.opts = t.opts || {}), Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then((t) => { const { statusCode: s, statusCode: a, headers: r, body: i, bodyBytes: o, } = t; e(null, { status: s, statusCode: a, headers: r, body: i, bodyBytes: o, }, i, o) }, (t) => e((t && t.error) || "UndefinedError")); break; case "Node.js": let a = require("iconv-lite"); this.initGotEnv(t); const { url: r, ...i } = t; this.got[s](r, i).then((t) => { const { statusCode: s, statusCode: r, headers: i, rawBody: o, } = t, n = a.decode(o, this.encoding); e(null, { status: s, statusCode: r, headers: i, rawBody: o, body: n }, n) }, (t) => { const { message: s, response: r } = t; e(s, r, r && a.decode(r.rawBody, this.encoding)) }) } } time(t, e = null) { const s = e ? new Date(e) : new Date(); let a = { "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 a) new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? a[e] : ("00" + a[e]).substr(("" + a[e]).length))); return t } queryStr(t) { let e = ""; for (const s in t) { let a = t[s]; null != a && "" !== a && ("object" == typeof a && (a = JSON.stringify(a)), (e += `${s}=${a}&`)) } return (e = e.substring(0, e.length - 1)), e } msg(e = t, s = "", a = "", r) { const i = (t) => { switch (typeof t) { case void 0: return t; case "string": switch (this.getEnv()) { case "Surge": case "Stash": default: return { url: t }; case "Loon": case "Shadowrocket": return t; case "Quantumult X": return { "open-url": t }; case "Node.js": return }case "object": switch (this.getEnv()) { case "Surge": case "Stash": case "Shadowrocket": default: { let e = t.url || t.openUrl || t["open-url"]; return { url: e } } case "Loon": { let e = t.openUrl || t.url || t["open-url"], s = t.mediaUrl || t["media-url"]; return { openUrl: e, mediaUrl: s } } case "Quantumult X": { let e = t["open-url"] || t.url || t.openUrl, s = t["media-url"] || t.mediaUrl, a = t["update-pasteboard"] || t.updatePasteboard; return { "open-url": e, "media-url": s, "update-pasteboard": a, } } case "Node.js": return }default: return } }; if (!this.isMute) switch (this.getEnv()) { case "Surge": case "Loon": case "Stash": case "Shadowrocket": default: $notification.post(e, s, a, i(r)); break; case "Quantumult X": $notify(e, s, a, i(r)); break; case "Node.js": }if (!this.isMuteLog) { let t = ["", "==============📣系统通知📣==============",]; t.push(e), s && t.push(s), a && t.push(a), 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) { switch (this.getEnv()) { case "Surge": case "Loon": case "Stash": case "Shadowrocket": case "Quantumult X": default: this.log("", `❗️${this.name},错误!`, t); break; case "Node.js": this.log("", `❗️${this.name},错误!`, t.stack) } } wait(t) { return new Promise((e) => setTimeout(e, t)) } DoubleLog(d) { if (this.isNode()) { if (d) { console.log(`${d}`); msg += `\n ${d}` } } else { console.log(`${d}`); msg += `\n ${d}` } } async SendMsg(m) { if (!m) return; if (Notify > 0) { if (this.isNode()) { var notify = require("../sendNotify"); await notify.sendNotify(this.name, m) } else { this.msg(this.name, "", m) } } else { console.log(m) } } done(t = {}) { const e = new Date().getTime(), s = (e - this.startTime) / 1e3; switch ((this.log("", `🔔${this.name},结束!🕛${s}秒`), this.log(), this.getEnv())) { case "Surge": case "Loon": case "Stash": case "Shadowrocket": case "Quantumult X": default: $done(t); break; case "Node.js": process.exit(1) } } })(t, e) } -//Env rewrite:smallfawn Update-time:23-6-30 newAdd:DoubleLog & SendMsg