From c44d490ad13915ca96d7c193ef25dd5413166f28 Mon Sep 17 00:00:00 2001 From: smallfawn <860562056@QQ.COM> Date: Sun, 5 Apr 2026 09:54:20 +0800 Subject: [PATCH] feat(new mswe.js): new mswe.js --- daily/maisiweier.js | 381 +++++++++++++++++++++++++++++ ljfsjlb.js | 583 -------------------------------------------- maisiweier.js | 415 ------------------------------- 3 files changed, 381 insertions(+), 998 deletions(-) create mode 100644 daily/maisiweier.js delete mode 100644 ljfsjlb.js delete mode 100644 maisiweier.js diff --git a/daily/maisiweier.js b/daily/maisiweier.js new file mode 100644 index 0000000..2937ecb --- /dev/null +++ b/daily/maisiweier.js @@ -0,0 +1,381 @@ +/* +------------------------------------------ +@Author: sm +@Date: 2024.06.07 19:15 +@Description: 麦斯威尔福利社小程序 签到 浇水 积分 +cron: 30 9 * * * +------------------------------------------ +#Notice: 麦斯威尔福利社小程序 +抓jde.mtbcpt.com/api的POST请求中的openId 多账户&或换行 +⚠️【免责声明】 +------------------------------------------ +1、此脚本仅用于学习研究,不保证其合法性、准确性、有效性,请根据情况自行判断,本人对此不承担任何保证责任。 +2、由于此脚本仅用于学习研究,您必须在下载后 24 小时内将所有内容从您的计算机或手机或任何存储设备中完全删除,若违反规定引起任何事件本人对此均不负责。 +3、请勿将此脚本用于任何商业或非法目的,若违反规定请自行对此负责。 +4、此脚本涉及应用与本人无关,本人对因此引起的任何隐私泄漏或其他后果不承担任何责任。 +5、本人对任何脚本引发的问题概不负责,包括但不限于由脚本错误引起的任何损失和损害。 +6、如果任何单位或个人认为此脚本可能涉嫌侵犯其权利,应及时通知并提供身份证明,所有权证明,我们将在收到认证文件确认后删除此脚本。 +7、所有直接或间接使用、查看此脚本的人均应该仔细阅读此声明。本人保留随时更改或补充此声明的权利。一旦您使用或复制了此脚本,即视为您已接受此免责声明。 +*/ + +const { Env } = require("./tools/env") +const $ = new Env("麦斯威尔福利社小程序"); +let ckName = `mswe`; +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.openId = this.user[0]; + + } + + async run() { + await this.getMemberTaskInfo() + await this.getUserFarmGetWaterList() + for (let i = 0; i < 3; i++) { + await this.farmWatering(); + } + } + + md5(str) { + const crypto = require("crypto") + return crypto.createHash("md5").update(str).digest('hex'); + } + // ============================================================================================================================= + + async getMemberTaskInfo() { + try { + let timestamp = Date.now(); + let sign = this.md5(`timestamp=${timestamp}&openid=${this.openId}&key=JDEMaxwellminiapp#2021!`).toUpperCase(); + let options = { + method: 'post', + url: 'https://jde.mtbcpt.com/api/JDEMaxwellApi/GetMemberTaskInfo', + headers: { + 'Host': 'jde.mtbcpt.com', + 'content-type': 'application/json', + 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF WindowsWechat(0x63090b11) XWEB/9129', + }, + data: { + "openId": this.openId, + "timestamp": timestamp, + "sign": sign, + } + }; + + let { data: result } = await axios.request(options) + + if (result?.state == true) { + + $.log(`🌸账号[${this.index}]` + `查询任务成功🎉`); + if (result.data.dailySign != 1) { + $.log(`${this.index}账号[${this.index}]` + `未签到`); + await this.signDailyScore() + + } else { + $.log(`${this.index}账号[${this.index}]` + `已签到`); + + + } + if (result.data.shareSign != 1) { + $.log(`${this.index}账号[${this.index}]` + `未分享`); + //分享 + await this.shareDailyScore() + } else { + $.log(`${this.index}账号[${this.index}]` + `已分享`); + + } + + } else { + $.log(`🌸账号[${this.index}]查询任务-失败:${result.msg}❌`) + } + + } catch (e) { + + } + } + async signDailyScore() { + try { + let timestamp = Date.now(); + let sign = this.md5(`timestamp=${timestamp}&openid=${this.openId}&key=JDEMaxwellminiapp#2021!`).toUpperCase(); + let options = { + method: 'post', + url: 'https://jde.mtbcpt.com/api/JDEMaxwellApi/SignInDailyScore', + headers: { + 'Host': 'jde.mtbcpt.com', + 'content-type': 'application/json', + 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF WindowsWechat(0x63090b11) XWEB/9129', + }, + data: { + "openId": this.openId, + "timestamp": timestamp, + "sign": sign, + } + }; + + let { data: result } = await axios.request(options) + + if (result?.state == true) { + + $.log(`🌸账号[${this.index}]` + `🕊${result.msg}🎉`); + } else { + $.log(`🌸账号[${this.index}]签到-失败:${result.msg}❌`) + } + + } catch (e) { + + } + } + //分享加积分 + async shareDailyScore() { + try { + let timestamp = Date.now(); + let sign = md5(`timestamp=${timestamp}&openid=${this.openId}&key=JDEMaxwellminiapp#2021!`).toUpperCase(); + let options = { + method: 'post', + url: `https://jde.mtbcpt.com/api/JDEMaxwellApi/ShareDailyScore`, + headers: { + 'Host': 'jde.mtbcpt.com', + 'content-type': 'application/json', + 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF WindowsWechat(0x63090b11) XWEB/9129', + }, + data: { + "through": true, + "openId": this.openId, + "timestamp": timestamp, + "sign": sign, + } + + } + // + let { data: result } = await axios.request(options) + + if (result?.state == true) { + //打印签到结果 + $.log(`🌸账号[${user.index}]` + `🕊${result.msg}🎉`); + } if (result?.state == false) { + $.log(`🌸账号[${user.index}]分享-失败:${result.msg}❌`) + } + } catch (e) { + + } + } + async getUserFarmGetWaterList() { + try { + let timestamp = Date.now(); + let sign = this.md5(`timestamp=${timestamp}&openid=${this.openId}&key=JDEMaxwellminiapp#2021!`).toUpperCase(); + let options = { + method: 'post', + url: 'https://jde.mtbcpt.com/api/JDEMaxwellApi/getUserFarmGetWaterList', + headers: { + 'Host': 'jde.mtbcpt.com', + 'content-type': 'application/json', + 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF WindowsWechat(0x63090b11) XWEB/9129', + }, + data: { + "openId": this.openId, + "timestamp": timestamp, + "sign": sign, + } + }; + + let { data: result } = await axios.request(options) + + if (result?.state == true) { + + $.log(`🌸账号[${this.index}]` + `查询农场任务成功🎉`); + for (let task of result.data.list) { + if (task.status != 3) { + $.log(`${this.index}账号[${this.index}][${task.taskName}]` + `未执行`); + if (task.ptype == 1) { + await this.farmSign() + } + if (task.ptype == 2) { + await this.farmShare() + } + } else { + $.log(`${this.index}账号[${this.index}][${task.taskName}]` + `已执行`); + + } + + } + + + + + + } else { + $.log(`🌸账号[${this.index}]查询任务-失败:${result.msg}❌`) + } + + } catch (e) { + + } + } + //浇水签到 + async farmSign() { + try { + let timestamp = Date.now(); + let sign = this.md5(`timestamp=${timestamp}&openid=${this.openId}&key=JDEMaxwellminiapp#2021!`).toUpperCase(); + let options = { + method: 'post', + url: 'https://jde.mtbcpt.com/api/JDEMaxwellApi/UserSign', + headers: { + 'Host': 'jde.mtbcpt.com', + 'content-type': 'application/json', + 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF WindowsWechat(0x63090b11) XWEB/9129', + }, + data: { + + "openId": this.openId, + "timestamp": timestamp, + "sign": sign, + + } + }; + let { data: result } = await axios.request(options) + if (result?.state == true) { + + $.log(`🌸账号[${this.index}]` + `🕊水滴签到-领取成功${result.msg}🎉`); + } else { + $.log(`🌸账号[${this.index}]水滴签到-失败:${result.msg}❌`) + } + + } catch (e) { + + } + } + //分享领水滴 + async farmShare() { + try { + let timestamp = Date.now(); + let sign = this.md5(`timestamp=${timestamp}&openid=${this.openId}&key=JDEMaxwellminiapp#2021!`).toUpperCase(); + let options = { + method: 'post', + url: 'https://jde.mtbcpt.com/api/JDEMaxwellApi/UserShare', + headers: { + 'Host': 'jde.mtbcpt.com', + 'content-type': 'application/json', + 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF WindowsWechat(0x63090b11) XWEB/9129', + }, + data: { + + "openId": this.openId, + "timestamp": timestamp, + "sign": sign, + + } + }; + + let { data: result } = await axios.request(options) + if (result?.state == true) { + + $.log(`🌸账号[${this.index}]` + `🕊任务分享领水滴-领取成功${result.msg}🎉`); + } else { + $.log(`🌸账号[${this.index}]任务分享领水滴-失败:${result.msg}❌`) + } + + } catch (e) { + + } + } + //浇水 + async farmWatering() { + try { + let timestamp = Date.now(); + let sign = this.md5(`timestamp=${timestamp}&openid=${this.openId}&key=JDEMaxwellminiapp#2021!`).toUpperCase(); + let options = { + method: 'post', + url: 'https://jde.mtbcpt.com/api/JDEMaxwellApi/UserWatering', + headers: { + 'Host': 'jde.mtbcpt.com', + 'content-type': 'application/json', + 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF WindowsWechat(0x63090b11) XWEB/9129', + }, + data: { + "openId": this.openId, + "timestamp": timestamp, + "sign": sign, + } + }; + + let { data: result } = await axios.request(options) + if (result?.state == true) { + + $.log(`🌸账号[${this.index}]` + `🕊浇水-成功${result.msg}🎉`); + } else { + $.log(`🌸账号[${this.index}]浇水-失败:${result.msg}❌`) + } + + } catch (e) { + + } + } + async getUserPoint() { + try { + let timestamp = Date.now() + let sign = this.md5(`timestamp=${timestamp}&openid=${this.openId}&key=JDEMaxwellminiapp#2021!`).toUpperCase(); + let options = { + method: 'post', + url: 'https://jde.mtbcpt.com/api/JDEMWMall/GetUserPoint', + headers: { + 'Host': 'jde.mtbcpt.com', + 'content-type': 'application/json', + 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF WindowsWechat(0x63090b11) XWEB/9129', + }, + data: { + + "openId": this.openId, + "timestamp": timestamp, + "sign": sign, + + } + }; + + let { data: result } = await axios.request(options) + if (result?.state == true) { + this.userFlag = false + $.log(`🌸账号[${this.index}]` + `🕊${result.msg}为[${result.data}]💰`); + } else { + $.log(`🌸账号[${this.index}]积分查询失败:${result.msg}❌`) + } + + } catch (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 +} diff --git a/ljfsjlb.js b/ljfsjlb.js deleted file mode 100644 index 819f6d6..0000000 --- a/ljfsjlb.js +++ /dev/null @@ -1,583 +0,0 @@ -/* -罗技粉丝俱乐部 - -自己捉api.wincheers.net包里的Authorization,去掉前面的Bearer之后填到ljfsjlbCookie里 -多账号换行或&隔开 -*/ -const $ = new Env("罗技粉丝俱乐部"); - -let envSplitor = ['\n','&'] -let httpErr, httpReq, httpResp - -let userCookie = ($.isNode() ? process.env.ljfsjlbCookie : $.getdata('ljfsjlbCookie')) || ''; - -let userList = [] -let userIdx = 0 -let userCount = 0 - -let VIDEO_TASK_NUM = 3 - -let contentType = 'application/json;charset=utf-8' -let client_id = 'LogitechFans' - -let defaultUA = 'Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.23(0x1800172f) NetType/WIFI Language/zh_CN' -let Referer = 'https://servicewechat.com/wx9be0a7d24db348e8/220/page-frame.html' -/////////////////////////////////////////////////////////////////// -class UserInfo { - constructor(str) { - this.index = ++userIdx - this.name = this.index - this.valid = false - - this.auth = str - this.taskList = {} - } - - async taskApi(fn,method,url,body) { - let result = null - try { - let host = url.replace('//','/').split('/')[1] - let urlObject = { - url: url, - headers: { - 'Host': host, - 'Connection': 'keep-alive', - 'User-Agent': defaultUA, - 'Referer': Referer, - 'client_id': client_id, - 'Authorization': 'Bearer ' + this.auth, - }, - timeout: 5000, - } - if(body) { - urlObject.body = body - urlObject.headers['Content-Type'] = contentType - } - await httpRequest(method,urlObject).then(async (ret) => { - if(ret.resp?.statusCode == 200) { - if(ret.resp?.body) { - result = JSON.parse(ret.resp.body) - } else { - console.log(`账号[${this.index}]调用${method}[${fn}]出错,返回为空`) - } - } else { - console.log(`账号[${this.index}]调用${method}[${fn}]出错,返回状态码[${ret.resp?.statusCode||''}]`) - } - }) - } catch(e) { - console.log(e) - } finally { - return Promise.resolve(result); - } - } - - async GetIsLogin() { - try { - let fn = 'GetIsLogin' - let method = 'post' - let url = `https://api.wincheers.net/api/services/app/crmAccount/GetIsLogin` - let body = `` - await this.taskApi(fn,method,url,body).then(async (result) => { - if(result.success==true) { - this.valid = true - this.name = result.result.name - this.id = result.result.id - this.integral = result.result.integral - this.phone = result.result.telephone - this.buyerNo = result.result.buyerNo - console.log(`登录成功`) - console.log(`昵称: ${this.name}`) - console.log(`ID: ${this.id}`) - console.log(`积分: ${this.integral}`) - } else { - $.logAndNotify(`账号[${this.index}]登录失败,CK失效`) - } - }) - } catch(e) { - console.log(e) - } finally { - return Promise.resolve(1); - } - } - - async IsSignDao() { - try { - let fn = 'IsSignDao' - let method = 'post' - let url = `https://api.wincheers.net/api/services/app/signIn/IsSignDao` - let body = `` - await this.taskApi(fn,method,url,body).then(async (result) => { - if(result.success==true) { - let taskDetail = result.result.split('|') - - this.taskList.IsSingDao = taskDetail[0] - this.taskList.SignDay = taskDetail[1] - this.taskList.IsNotice = taskDetail[2] - this.taskList.Integral = taskDetail[3] - this.taskList.VideoNum = taskDetail[4] - this.taskList.shareNum = taskDetail[5] - this.taskList.Isperfect = taskDetail[6] - this.taskList.IsRelease = taskDetail[7] - this.taskList.IsBangDing = taskDetail[8] - this.taskList.IsForward = taskDetail[9] - this.taskList.Iscomment = taskDetail[10] - this.taskList.isProbe = taskDetail[11] - this.taskList.isInterest = taskDetail[12] - this.taskList.InviteNum = taskDetail[13] - - if(this.taskList.IsSingDao != 'ok') { - await this.ContinuitySignIn(); - } else { - console.log(`今天已签到,已签到${this.taskList.SignDay}天`) - } - if(this.taskList.VideoNum < VIDEO_TASK_NUM) { - let num = VIDEO_TASK_NUM - this.taskList.VideoNum - for(let i=0; i { - if(result.success==true) { - this.taskList.SignDay++ - console.log(`签到成功,获得${result.result}积分,已签到${this.taskList.SignDay}天`) - } else { - console.log(`签到失败:${result?.error?.message}`) - } - }) - } catch(e) { - console.log(e) - } finally { - return Promise.resolve(1); - } - } - - async AddLogVideo(SocialId) { - try { - let fn = 'AddLogVideo' - let method = 'post' - let url = `https://api.wincheers.net/api/services/app/socialVideoOverLog/AddLog?SocialId=${SocialId}` - let body = `` - await this.taskApi(fn,method,url,body).then(async (result) => { - if(result.success==true) { - console.log(`观看视频成功`) - if(result.result > 0) console.log(`完成观看视频任务成功,获得${result.result}积分`) - } else { - console.log(`观看视频失败:${result?.error?.message}`) - } - }) - } catch(e) { - console.log(e) - } finally { - return Promise.resolve(1); - } - } - - async GiftPoints() { - try { - let fn = 'GiftPoints' - let method = 'post' - let url = `https://api.wincheers.net/api/services/app/crmAccount/GiftPoints` - let body = `` - await this.taskApi(fn,method,url,body).then(async (result) => { - if(result.success==true) { - console.log(`分享成功,每天首次分享可得50积分`) - } else { - console.log(`分享失败:${result?.error?.message}`) - } - }) - } catch(e) { - console.log(e) - } finally { - return Promise.resolve(1); - } - } - - async userTask() { - try { - console.log(`\n============= 账号[${this.index}] =============`) - await this.getScoreAccount(); - } catch(e) { - console.log(e) - } finally { - return Promise.resolve(1); - } - } -} - -!(async () => { - if (typeof $request !== "undefined") { - await GetRewrite() - }else { - if(!(await checkEnv())) return; - - console.log('\n================ 登录 ================') - for(let user of userList) { - console.log(`----------- 账号[${user.index}] -----------`) - await user.GetIsLogin(); - } - - let validUserList = userList.filter(x => x.valid) - - if(validUserList.length > 0) { - console.log('\n================ 任务 ================') - for(let user of validUserList) { - console.log(`----------- 账号[${user.index}] -----------`) - await user.IsSignDao(); - } - } - - await $.showmsg(); - } -})() -.catch((e) => console.log(e)) -.finally(() => $.done()) - -/////////////////////////////////////////////////////////////////// -async function GetRewrite() { -} - -async function checkEnv() { - if(userCookie) { - let splitor = envSplitor[0]; - for(let sp of envSplitor) { - if(userCookie.indexOf(sp) > -1) { - splitor = sp; - break; - } - } - for(let userCookies of userCookie.split(splitor)) { - if(userCookies) userList.push(new UserInfo(userCookies)) - } - userCount = userList.length - } else { - console.log('未找到CK') - return; - } - - console.log(`共找到${userCount}个账号`) - return true -} -//////////////////////////////////////////////////////////////////// -async function httpRequest(method,url) { - httpErr=null, httpReq=null, httpResp=null; - return new Promise((resolve) => { - $.send(method, url, async (err, req, resp) => { - httpErr=err, httpReq=req, httpResp=resp; - resolve({err,req,resp}) - }) - }); -} -//////////////////////////////////////////////////////////////////// -function Env(name,env) { - "undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0); - return new class { - constructor(name,env) { - this.name = name - this.notifyStr = '' - this.startTime = (new Date).getTime() - Object.assign(this,env) - console.log(`${this.name} 开始运行:\n`) - } - 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 - } - 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 - } - send(m, t, e = (() => {})) { - if(m != 'get' && m != 'post' && m != 'put' && m != 'delete') { - console.log(`无效的http方法:${m}`); - return; - } - if(m == 'get' && t.headers) { - delete t.headers["Content-Type"]; - delete t.headers["Content-Length"]; - } else if(t.body && t.headers) { - if(!t.headers["Content-Type"]) t.headers["Content-Type"] = "application/x-www-form-urlencoded"; - } - if(this.isSurge() || this.isLoon()) { - if(this.isSurge() && this.isNeedRewrite) { - t.headers = t.headers || {}; - Object.assign(t.headers, {"X-Surge-Skip-Scripting": !1}); - } - let conf = { - method: m, - url: t.url, - headers: t.headers, - timeout: t.timeout, - data: t.body - }; - if(m == 'get') delete conf.data - $axios(conf).then(t => { - const { - status: i, - request: q, - headers: r, - data: o - } = t; - e(null, q, { - statusCode: i, - headers: r, - body: o - }); - }).catch(err => console.log(err)) - } else if (this.isQuanX()) { - t.method = m.toUpperCase(), this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { - hints: !1 - })), - $task.fetch(t).then(t => { - const { - statusCode: i, - request: q, - headers: r, - body: o - } = t; - e(null, q, { - statusCode: i, - headers: r, - body: o - }) - }, t => e(t)) - } else if (this.isNode()) { - this.got = this.got ? this.got : require("got"); - const { - url: s, - ...i - } = t; - this.instance = this.got.extend({ - followRedirect: false - }); - this.instance[m](s, i).then(t => { - const { - statusCode: i, - request: q, - headers: r, - body: o - } = t; - e(null, q, { - statusCode: i, - headers: r, - body: o - }) - }, t => { - const { - message: s, - request: q, - response: i - } = t; - e(s, q, i) - }) - } - } - time(t,x=null) { - let xt = x ? new Date(x) : new Date - let e = { - "M+": xt.getMonth() + 1, - "d+": xt.getDate(), - "h+": xt.getHours(), - "m+": xt.getMinutes(), - "s+": xt.getSeconds(), - "q+": Math.floor((xt.getMonth() + 3) / 3), - S: xt.getMilliseconds() - }; - /(y+)/.test(t) && (t = t.replace(RegExp.$1, (xt.getFullYear() + "").substr(4 - RegExp.$1.length))); - for (let s in e) - new RegExp("(" + s + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? e[s] : ("00" + e[s]).substr(("" + e[s]).length))); - return t - } - async showmsg() { - if(!this.notifyStr) return; - let notifyBody = this.name + " 运行通知\n\n" + this.notifyStr - if($.isNode()){ - var notify = require('./sendNotify'); - console.log('\n============== 推送 ==============') - await notify.sendNotify(this.name, notifyBody); - } else { - this.msg(notifyBody); - } - } - logAndNotify(str) { - console.log(str) - this.notifyStr += str - this.notifyStr += '\n' - } - logAndNotifyWithTime(str) { - let t = '['+this.time('hh:mm:ss.S')+']'+str - console.log(t) - this.notifyStr += t - this.notifyStr += '\n' - } - logWithTime(str) { - console.log('['+this.time('hh:mm:ss.S')+']'+str) - } - 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 - } - } - } - }; - this.isMute || (this.isSurge() || this.isLoon() ? $notification.post(e, s, i, o(r)) : this.isQuanX() && $notify(e, s, i, o(r))); - let h = ["", "============== 系统通知 =============="]; - h.push(e), - s && h.push(s), - i && h.push(i), - console.log(h.join("\n")) - } - getMin(a,b){ - return ((anumStr.length) ? (length-numStr.length) : 0 - let retStr = '' - for(let i=0; i setTimeout(e, t)) - } - done(t = {}) { - const e = (new Date).getTime(), - s = (e - this.startTime) / 1e3; - console.log(`\n${this.name} 运行结束,共运行了 ${s} 秒!`) - if(this.isSurge() || this.isQuanX() || this.isLoon()) $done(t) - } - }(name,env) -} diff --git a/maisiweier.js b/maisiweier.js deleted file mode 100644 index 95941e4..0000000 --- a/maisiweier.js +++ /dev/null @@ -1,415 +0,0 @@ - -/** - - * 麦斯威尔福利社 - * mswefls - * Author: Mist - * Date: 2024-07-20 - * cron "10 12 * * *" mswefls.js - * export mswefls= openid 多账号换行或者#分隔 - */ -// ============================================================================================================ -const $ = new Env('vx麦斯威尔福利社') -const axios = require('axios') -const md5 = require('md5') -const env_name = 'mswefls' //环境变量名字 -const env = process.env[env_name] || '' //获取环境变量 -const Notify = 1//是否通知, 1通知, 0不通知. 默认通知 -const debug = 0//是否调试, 1调试, 0不调试. 默认不调试 -let scriptVersionNow = "1.0.0";//脚本版本号 -let msg = ""; -// ==================================异步顺序============================================================================== -!(async () => { - //await getNotice(); //远程通知 - //await getVersion("yang88758/ohhh154@main/mswefls.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 openId = ck_info[0] - let user = { - index: index, - openId, - } - index = index + 1 //每次用完序号+1 - //开始账号任务 - await userTask(user) - //每个账号之间等1~5秒随机时间 - let rnd_time = Math.floor(Math.random() * 4000) + 1000 - console.log(`账号[${user.index}]随机等待${rnd_time / 1000}秒...`) - await $.wait(rnd_time) - } -} -// ======================================开始任务========================================= -async function userTask(user) { - console.log(`\n============= 账号[${user.index}]开始任务 =============`) - await wait (1) - await SignInDailyScore(user) - await wait (1) - await ShareDailyScore(user) - await wait (1) - await UserSign(user) - await wait (1) - await UserShare(user) - await wait (1) - for (let i = 0; i < 3; i++) { - await Watering(user); - await wait (2) - } - await GetUserPoint(user) - -} -// ============================================================================================================================= -//签到 -async function SignInDailyScore(user) { - try { - let timestamp = getTimestamp(); - let sign = md5(`timestamp=${timestamp}&openid=${user.openId}&key=JDEMaxwellminiapp#2021!`).toUpperCase(); - let urlObject = { - method: 'post', - url: 'https://jde.mtbcpt.com/api/JDEMaxwellApi/SignInDailyScore', - headers: { - 'Host': 'jde.mtbcpt.com', - 'content-type': 'application/json', - 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF WindowsWechat(0x63090b11) XWEB/9129', - }, - data: { - "openId": user.openId, - "timestamp": timestamp, - "sign": sign, - } - }; - //console.log(urlObject); - let { data: result} = await axios.request(urlObject) - if (result?.state == true) { - //打印签到结果 - DoubleLog(`🌸账号[${user.index}]` + `🕊${result.msg}🎉`); - }else{ - DoubleLog(`🌸账号[${user.index}]签到-失败:${result.msg}❌`) - } - - } catch (e) { - //打印错误信息 - console.log('以下是报错输出:'); - console.log(e); - } -} -//分享加积分 -async function ShareDailyScore(user) { - try { - let timestamp = getTimestamp(); - let sign = md5(`timestamp=${timestamp}&openid=${user.openId}&key=JDEMaxwellminiapp#2021!`).toUpperCase(); - let urlObject = { - method: 'post', - url: `https://jde.mtbcpt.com/api/JDEMaxwellApi/ShareDailyScore`, - headers: { - 'Host': 'jde.mtbcpt.com', - 'content-type': 'application/json', - 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF WindowsWechat(0x63090b11) XWEB/9129', - }, - data:{ - "through": true, - "openId": user.openId, - "timestamp": timestamp, - "sign": sign, - } - - } - // - let { data: result} = await axios.request(urlObject) - //console.log(urlObject); - //console.log(result); - if (result?.state == true) { - //打印签到结果 - DoubleLog(`🌸账号[${user.index}]` + `🕊${result.msg}🎉`); - }if(result?.state == false) { - DoubleLog(`🌸账号[${user.index}]分享-失败:${result.msg}❌`) - } - } catch (e) { - //打印错误信息 - console.log(e.response.data); - } -} -//浇水签到 -async function UserSign(user) { - try { - let timestamp = getTimestamp(); - let sign = md5(`timestamp=${timestamp}&openid=${user.openId}&key=JDEMaxwellminiapp#2021!`).toUpperCase(); - let urlObject = { - method: 'post', - url: 'https://jde.mtbcpt.com/api/JDEMaxwellApi/UserSign', - headers: { - 'Host': 'jde.mtbcpt.com', - 'content-type': 'application/json', - 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF WindowsWechat(0x63090b11) XWEB/9129', - }, - data: { - - "openId": user.openId, - "timestamp": timestamp, - "sign": sign, - - } - }; - //console.log(urlObject); - let { data: result} = await axios.request(urlObject) - if (result?.state == true) { - //打印签到结果 - DoubleLog(`🌸账号[${user.index}]` + `🕊水滴签到-领取成功${result.msg}🎉`); - }else{ - DoubleLog(`🌸账号[${user.index}]水滴签到-失败:${result.msg}❌`) - } - - } catch (e) { - //打印错误信息 - console.log('以下是报错输出:'); - console.log(e.response.data); - } -} -//分享领水滴 -async function UserShare(user) { - try { - let timestamp = getTimestamp(); - let sign = md5(`timestamp=${timestamp}&openid=${user.openId}&key=JDEMaxwellminiapp#2021!`).toUpperCase(); - let urlObject = { - method: 'post', - url: 'https://jde.mtbcpt.com/api/JDEMaxwellApi/UserShare', - headers: { - 'Host': 'jde.mtbcpt.com', - 'content-type': 'application/json', - 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF WindowsWechat(0x63090b11) XWEB/9129', - }, - data: { - - "openId": user.openId, - "timestamp": timestamp, - "sign": sign, - - } - }; - //console.log(urlObject); - let { data: result} = await axios.request(urlObject) - if (result?.state == true) { - //打印签到结果 - DoubleLog(`🌸账号[${user.index}]` + `🕊任务分享领水滴-领取成功${result.msg}🎉`); - }else{ - DoubleLog(`🌸账号[${user.index}]任务分享领水滴-失败:${result.msg}❌`) - } - - } catch (e) { - //打印错误信息 - console.log('以下是报错输出:'); - console.log(e.response.data); - } -} -//浇水 -async function Watering(user) { - try { - let timestamp = getTimestamp(); - let sign = md5(`timestamp=${timestamp}&openid=${user.openId}&key=JDEMaxwellminiapp#2021!`).toUpperCase(); - let urlObject = { - method: 'post', - url: 'https://jde.mtbcpt.com/api/JDEMaxwellApi/UserWatering', - headers: { - 'Host': 'jde.mtbcpt.com', - 'content-type': 'application/json', - 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF WindowsWechat(0x63090b11) XWEB/9129', - }, - data: { - - "openId": user.openId, - "timestamp": timestamp, - "sign": sign, - - } - }; - //console.log(urlObject); - let { data: result} = await axios.request(urlObject) - if (result?.state == true) { - //打印签到结果 - DoubleLog(`🌸账号[${user.index}]` + `🕊浇水-成功${result.msg}🎉`); - }else{ - DoubleLog(`🌸账号[${user.index}]浇水-失败:${result.msg}❌`) - } - - } catch (e) { - //打印错误信息 - console.log('以下是报错输出:'); - console.log(e.response.data); - } -} -async function GetUserPoint(user) { - try { - let timestamp = getTimestamp(); - let sign = md5(`timestamp=${timestamp}&openid=${user.openId}&key=JDEMaxwellminiapp#2021!`).toUpperCase(); - let urlObject = { - method: 'post', - url: 'https://jde.mtbcpt.com/api/JDEMWMall/GetUserPoint', - headers: { - 'Host': 'jde.mtbcpt.com', - 'content-type': 'application/json', - 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF WindowsWechat(0x63090b11) XWEB/9129', - }, - data: { - - "openId": user.openId, - "timestamp": timestamp, - "sign": sign, - - } - }; - //console.log(urlObject); - let { data: result} = await axios.request(urlObject) - if (result?.state == true) { - //打印签到结果 - DoubleLog(`🌸账号[${user.index}]` + `🕊${result.msg}为[${result.data}]💰`); - }else{ - DoubleLog(`🌸账号[${user.index}]积分查询失败:${result.msg}❌`) - } - - } catch (e) { - //打印错误信息 - console.log('以下是报错输出:'); - console.log(e.response.data); - } -} -/** - * =========================================================发送消息============================================= - */ -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 = [ - "http://tfapi.cn/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] : ""; - console.log(`\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