Files
XiaoGe-LiBai-yangmao/植白说.js
2023-08-11 23:43:40 +08:00

67 lines
19 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
*
* cron 10 7 * * *
*
* ========= 青龙--配置文件 ===========
*
* 项目名称: #小程序://植白说/g35xB3V1IuedCpz
*
* export LiHua_zbs='userId&x-dts-token'
*
* 抓zbs.20171026.com域名下的x-dts-token
* 多账号用 换行 或 @ 分割
*
* ====================================
* 将utils.js文件放到同目录下
*/
//-------------------- 自定义变量区域 -------------------------------------
const Notify = 1; //0为关闭通知,1为打开通知,默认为1
const $=new Env("\u8BF4\u767D\u690D".split("").reverse().join(""));const ckName="sbz_auHiL".split("").reverse().join("");let utils=require("slitu/.".split("").reverse().join(""));const notify=$["\u0069\u0073\u004e\u006f\u0064\u0065"]()?require("yfitoNdnes/.".split("").reverse().join("")):"".split("").reverse().join("");let debug=0x405d6^0x405d6;let envSplitor=["\u0040",'\x0a'];let ck=msg="";let host,hostname;let userCookie=($["\u0069\u0073\u004e\u006f\u0064\u0065"]()?process['env'][ckName]:$['getdata'](ckName))||"".split("").reverse().join("");let userList=[];let userIdx=0x26bb4^0x26bb4;let userCount=0x66552^0x66552;let userId;async function start(){console["\u006c\u006f\u0067"]("================== \u672C\u811A\u884C\u6267 ==================".split("").reverse().join(""));taskall=[];for(let _0x39b4ae of userList){console["\u006c\u006f\u0067"]("----------------- \u606F\u4FE1\u6237\u7528 ----------------".split("").reverse().join(""));taskall['push'](await _0x39b4ae["\u0075\u0073\u0065\u0072\u005f\u0069\u006e\u0066\u006f"]("\u606F\u4FE1\u6237\u7528".split("").reverse().join("")));console["\u006c\u006f\u0067"]("------------------ \u5230\u7B7E ------------------".split("").reverse().join(""));taskall['push'](await _0x39b4ae["\u0075\u0073\u0065\u0072\u005f\u0073\u0069\u0067\u006e"]("\u5230\u7B7E".split("").reverse().join("")));await wait(0x52217^0x52216);console['log']('------------------\x20分享\x20------------------');for(let _0x5eb674=0xbf386^0xbf386;_0x5eb674<(0x8be48^0x8be4b);_0x5eb674++){await wait(0xa4d9d^0xa4d9e);taskall["\u0070\u0075\u0073\u0068"](await _0x39b4ae['user_share']("\u4EAB\u5206".split("").reverse().join("")));}console["\u006c\u006f\u0067"]('----------------\x20积分查询\x20----------------');taskall['push'](await _0x39b4ae['user_info1']('积分查询'));}await Promise["\u0061\u006c\u006c"](taskall);}class UserInfo{constructor(_0x1f404c){this["\u0069\u006e\u0064\u0065\u0078"]=++userIdx;this['ck']=_0x1f404c["\u0073\u0070\u006c\u0069\u0074"]("\u0026");this["\u0068\u006f\u0073\u0074"]="\u007a\u0062\u0073\u002e\u0032\u0030\u0031\u0037\u0031\u0030\u0032\u0036\u002e\u0063\u006f\u006d";this["\u0068\u006f\u0073\u0074\u006e\u0061\u006d\u0065"]='https://'+this["\u0068\u006f\u0073\u0074"];}async["\u0075\u0073\u0065\u0072\u005f\u0069\u006e\u0066\u006f"](_0x573637){try{let _0x5dfcc3={'method':"\u0047\u0065\u0074",'url':this["\u0068\u006f\u0073\u0074\u006e\u0061\u006d\u0065"]+'/demo/wx/user/getUserIntegral',"\u0068\u0065\u0061\u0064\u0065\u0072\u0073":{'Host':this["\u0068\u006f\u0073\u0074"],'charset':'\x20utf-8',"\u0078\u002d\u0064\u0074\u0073\u002d\u0074\u006f\u006b\u0065\u006e":this["\u0063\u006b"][0x62fef^0x62fef],'User-Agent':'Apifox/1.0.0\x20(https://apifox.com)','content-type':'\x20application/json','Accept':'*/*',"\u0043\u006f\u006e\u006e\u0065\u0063\u0074\u0069\u006f\u006e":"\u006b\u0065\u0065\u0070\u002d\u0061\u006c\u0069\u0076\u0065"}};let _0x66fc9d=await httpRequest(_0x5dfcc3,_0x573637);if(_0x66fc9d['errno']==(0xdec37^0xdec37)){DoubleLog("\u8d26\u53f7\u005b"+this["\u0069\u006e\u0064\u0065\u0078"]+']\x20\x20欢迎用户:\x20'+_0x66fc9d['data']['list'][0x2f860^0x2f860]["\u0075\u0073\u0065\u0072\u004e\u0061\u006d\u0065"]+"\uff0c"+_0x66fc9d["\u0064\u0061\u0074\u0061"]['integer']);userId=_0x66fc9d["\u0064\u0061\u0074\u0061"]["\u006c\u0069\u0073\u0074"][0x0]["\u0075\u0073\u0065\u0072\u0049\u0064"];}else{DoubleLog("[\u53F7\u8D26".split("").reverse().join("")+this['index']+']\x20\x20用户查询:失败\x20❌\x20了呢,'+_0x66fc9d['errmsg']);}}catch(_0xfbd3a9){console["\u006c\u006f\u0067"](_0xfbd3a9);}}async["\u0075\u0073\u0065\u0072\u005f\u0073\u0069\u0067\u006e"](_0x128f77){try{let _0xeb3362={'method':'Get','url':this['hostname']+'/demo/wx/home/signDay?userId='+userId,"\u0068\u0065\u0061\u0064\u0065\u0072\u0073":{"\u0048\u006f\u0073\u0074":this["\u0068\u006f\u0073\u0074"],'charset':'\x20utf-8','X-DTS-Token':this['ck'][0x0],'User-Agent':'Apifox/1.0.0\x20(https://apifox.com)','content-type':'\x20application/json','Accept':"\u002a\u002f\u002a","\u0043\u006f\u006e\u006e\u0065\u0063\u0074\u0069\u006f\u006e":'keep-alive'}};let _0x4c556d=await httpRequest(_0xeb3362,_0x128f77);if(_0x4c556d['errno']==0x0){DoubleLog('账号['+this['index']+']\x20\x20签到成功:\x20'+_0x4c556d["\u0065\u0072\u0072\u006d\u0073\u0067"]);}else{DoubleLog("\u8d26\u53f7\u005b"+this['index']+",\u5462\u4E86 \u274C \u8D25\u5931\u5230\u7B7E ]".split("").reverse().join("")+_0x4c556d['errmsg']);}}catch(_0x1a582e){console['log'](_0x1a582e);}}async["erahs_resu".split("").reverse().join("")](_0x2f0ea1){try{let _0x161a10={'method':"\u0047\u0065\u0074","\u0075\u0072\u006c":this['hostname']+"=dIresu?erahSyBlargetnIdda/resu/xw/omed/".split("").reverse().join("")+userId,'headers':{'Host':this['host'],"\u0063\u0068\u0061\u0072\u0073\u0065\u0074":'\x20utf-8','x-dts-token':this["\u0063\u006b"][0x0],"\u0055\u0073\u0065\u0072\u002d\u0041\u0067\u0065\u006e\u0074":'Apifox/1.0.0\x20(https://apifox.com)','content-type':'\x20application/json','Accept':'*/*','Connection':"\u006b\u0065\u0065\u0070\u002d\u0061\u006c\u0069\u0076\u0065"}};let _0x1ff077=await httpRequest(_0x161a10,_0x2f0ea1);if(_0x1ff077["\u0065\u0072\u0072\u006e\u006f"]==(0xbf0b8^0xbf0b8)){DoubleLog("[\u53F7\u8D26".split("").reverse().join("")+this["\u0069\u006e\u0064\u0065\u0078"]+']\x20\x20'+_0x2f0ea1+("".split("").reverse().join("")+_0x1ff077['errmsg']));}else{DoubleLog('账号['+this['index']+']\x20\x20分享失败\x20❌\x20了呢,'+_0x1ff077["\u0065\u0072\u0072\u006d\u0073\u0067"]);}}catch(_0x6ff63f){console['log'](_0x6ff63f);}}async["\u0075\u0073\u0065\u0072\u005f\u0069\u006e\u0066\u006f\u0031"](_0x54585e){try{let _0x47028b={'method':'Get','url':this['hostname']+"=dIresu?largetnIresUteg/resu/xw/omed/".split("").reverse().join("")+userId,'headers':{'Host':this['host'],'charset':'\x20utf-8','x-dts-token':this['ck'][0x0],'User-Agent':'Apifox/1.0.0\x20(https://apifox.com)',"\u0063\u006f\u006e\u0074\u0065\u006e\u0074\u002d\u0074\u0079\u0070\u0065":'\x20application/json',"\u0041\u0063\u0063\u0065\u0070\u0074":'*/*',"\u0043\u006f\u006e\u006e\u0065\u0063\u0074\u0069\u006f\u006e":"\u006b\u0065\u0065\u0070\u002d\u0061\u006c\u0069\u0076\u0065"}};let _0x5670dc=await httpRequest(_0x47028b,_0x54585e);if(_0x5670dc["\u0065\u0072\u0072\u006e\u006f"]==0x0){DoubleLog('账号['+this['index']+" :\u8BE2\u67E5\u5206\u79EF ]".split("").reverse().join("")+_0x5670dc['data']['integer']);}else{DoubleLog('账号['+this['index']+",\u5462\u4E86 \u274C \u8D25\u5931:\u8BE2\u67E5\u5206\u79EF ]".split("").reverse().join("")+_0x5670dc['errmsg']);}}catch(_0x3351a3){console["\u006c\u006f\u0067"](_0x3351a3);}}}
!(async () => {
if (!(await checkEnv())) return;
if (userList.length > 0) {
await start();
}
await SendMsg(msg);
})()
.catch((e) => console.log(e))
.finally(() => $.done());
// #region ******************************************************** 固定代码 ********************************************************
// 变量检查与处理
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}个账号 ================`),
console.log(`脚本执行✌北京时间(UTC+8)${new Date(new Date().getTime() + new Date().getTimezoneOffset() * 60 * 1000 + 8 * 60 * 60 * 1000).toLocaleString()}`), true;//true == !0
}
// =========================================== 不懂不要动 =========================================================
// 网络请求 (get, post等)
async function httpRequest(options, name) { var request = require("request"); return new Promise((resolve) => { if (!name) { let tmp = arguments.callee.toString(); let re = /function\s*(\w*)/i; let matches = re.exec(tmp); name = matches[1] } if (debug) { console.log(`\n【debug】===============这是${name}请求信息===============`); console.log(options) } request(options, function (error, response) { if (error) throw new Error(error); let data = response.body; try { if (debug) { console.log(`\n\n【debug】===============这是${name}返回数据==============`); console.log(data) } if (typeof data == "string") { if (isJsonString(data)) { let result = JSON.parse(data); if (debug) { console.log(`\n【debug】=============这是${name}json解析后数据============`); console.log(result) } resolve(result) } else { let result = data; resolve(result) } function isJsonString(str) { if (typeof str == "string") { try { if (typeof JSON.parse(str) == "object") { return true } } catch (e) { return false } } return false } } else { let result = data; resolve(result) } } catch (e) { console.log(error, response); console.log(`\n ${name}失败了!请稍后尝试!!`) } finally { resolve() } }) }) }
// 等待 X 秒
function wait(n) { return new Promise(function (resolve) { setTimeout(resolve, n * 1000) }) }
// 双平台log输出
function DoubleLog(data) { if ($.isNode()) { if (data) { console.log(`${data}`); msg += `${data}` } } else { console.log(`${data}`); msg += `${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) }