add:hezj

This commit is contained in:
smallfawn committed 2026-04-07 15:05:19 +08:00
1 parent 9f396f6da9
commit 4e50a97e36
10 files changed
+172 -2060

No files matched your search

+35 -44
View File
@@ -5,8 +5,9 @@ on:
branches:
- main
paths:
- '**/*.js'
- '**/*.py'
- 'daily/**' # 仅监控 daily 目录下的变更
- '!daily/notify.py' # 排除 notify.py
- '!daily/**/*.md' # 排除 md 文件
jobs:
update-readme:
@@ -35,87 +36,81 @@ jobs:
import datetime
import subprocess
# 1. 获取更改的文件列表(最近一次提交)
# 1. 获取更改的文件列表
try:
# 获取当前提交与上一次提交之间的差异文件
diff_cmd = ['git', 'diff', '--name-only', 'HEAD~1', 'HEAD']
result = subprocess.run(diff_cmd, capture_output=True, text=True, check=True)
changed_files = result.stdout.splitlines()
except subprocess.CalledProcessError:
# 如果没有上一次提交(例如第一次提交),则检查所有文件
diff_cmd = ['git', 'diff', '--name-only', '--cached']
result = subprocess.run(diff_cmd, capture_output=True, text=True, check=True)
changed_files = result.stdout.splitlines()
except Exception:
changed_files = []
# 筛选出 .js 或 .py 且实际存在的文件
target_files = [f for f in changed_files if (f.endswith('.js') or f.endswith('.py')) and os.path.exists(f)]
# 2. 筛选逻辑:必须在 daily 目录下,且不是 notify.py 和 .md 文件
target_files = []
for f in changed_files:
# 检查文件是否在 daily 目录下且文件存在
if f.startswith('daily/') and os.path.exists(f):
filename = os.path.basename(f)
# 排除 notify.py 和所有 .md 后缀文件
if filename != 'notify.py' and not f.endswith('.md'):
target_files.append(f)
if not target_files:
print("没有检测到相关脚本文件的变更,退出。")
print("没有检测到符合条件的脚本文件变更(排除 notify.py 和 md),退出。")
exit(0)
# 2. 从变更文件中提取 Env 名称
# 3. 提取 Env 名称
now = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
updates = {}
for f in target_files:
with open(f, 'r', encoding='utf-8') as file:
content = file.read()
# 匹配 Env("名称") 或 Env('名称')
match = re.search(r'Env\s*\(\s*["\']([^"\']+)["\']\s*\)', content)
if match:
updates[match.group(1)] = now
if not updates:
print("变更的脚本文件中未找到 Env 标签,退出。")
print("变更的脚本中未找到 Env 标签,退出。")
exit(0)
# 3. 修改 README.md 中的表格
# 4. 修改 README.md
readme_path = 'README.md'
if not os.path.exists(readme_path):
print("README.md 不存在!")
exit(1)
with open(readme_path, 'r', encoding='utf-8') as f:
full_text = f.read()
# 定义锚点标记(请确保 README.md 中已添加这两个注释)
start_tag = "<!-- README_TABLE_START -->"
end_tag = "<!-- README_TABLE_END -->"
start_tag = ""
end_tag = ""
if start_tag not in full_text or end_tag not in full_text:
print("错误:在 README.md 中未找到锚点标记!")
print("请添加以下两行注释包裹表格区域:")
print(f"{start_tag}")
print(f"{end_tag}")
print("错误:未找到锚点标记!")
exit(1)
# 分割文本
pre_part, temp = full_text.split(start_tag)
table_section, post_part = temp.split(end_tag)
# 解析现有表格
lines = table_section.strip().split('\n')
header = []
separator = []
body_lines = []
header, separator, body_lines = [], [], []
mode = 'header'
for line in lines:
line_stripped = line.strip()
if not line_stripped.startswith('|'):
continue
if '脚本名称' in line_stripped:
l_s = line.strip()
if not l_s.startswith('|'): continue
if '脚本名称' in l_s:
header.append(line)
mode = 'separator'
elif '---' in line_stripped and mode == 'separator':
elif '---' in l_s and mode == 'separator':
separator.append(line)
mode = 'body'
else:
if mode == 'body':
body_lines.append(line)
elif mode == 'body':
body_lines.append(line)
if not header or not separator:
print("错误:README 表格格式无效,缺少表头或分隔行。")
exit(1)
# 更新已有行,并记录已存在的脚本名称
existing_names = set()
new_body_lines = []
for line in body_lines:
@@ -127,20 +122,16 @@ jobs:
line = f"| {name} | {updates[name]} | ✅ |"
new_body_lines.append(line)
# 添加新增的脚本
for name, tm in updates.items():
if name not in existing_names:
new_body_lines.append(f"| {name} | {tm} | ✅ |")
# 重新组合完整表格
final_table = "\n".join(header + separator + new_body_lines)
final_content = f"{pre_part}{start_tag}\n{final_table}\n{end_tag}{post_part}"
# 写回 README.md
with open(readme_path, 'w', encoding='utf-8') as f:
f.write(final_content)
print("README.md 表格更新成功。")
print("README.md 更新成功。")
EOF
python update_readme.py
@@ -151,8 +142,8 @@ jobs:
git config --local user.name "github-actions[bot]"
git add README.md
if ! git diff --staged --quiet; then
git commit -m "docs: 自动更新脚本状态 [skip ci]"
git commit -m "docs: 自动更新 daily 脚本状态 [skip ci]"
git push
else
echo "README.md 无变更,无需提交。"
echo "无变更需推送。"
fi
-293
View File
@@ -1,293 +0,0 @@
/**
* 海尔智家
* cron 8 1 * * * hezj.js
* 活动入口 首页 智慧小屋
* 2023/03/18 修复BUG
* ========= 青龙--配置文件 ===========
* # 项目名称
* export hezj_data='token&clientId @ token&clientId '
*
* 多账号用 换行 或 @ 分割
* 抓包 https://mps.haiersmarthomes.com/api-gw , 找到accounttoken/accesstoken & clientId即可
* ====================================
*
*/
const $ = new Env("海尔智家");
const ckName = "hezj_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================== 用户CK ==================\n');
taskall = [];
for (let user of userList) {
taskall.push(await user.task_userinfo());
await $.wait(3000); //延迟 1秒 可充分利用 $.环境函数
}
await Promise.all(taskall);
console.log('\n================== 用户签到 ==================\n');
taskall = [];
for (let user of userList) {
if (user.ckStatus) {
taskall.push(await user.task_signin());
await $.wait(3000); //延迟 1秒 可充分利用 $.环境函数
}
}
await Promise.all(taskall);
console.log('\n================== 获取任务列表 ==================\n');
taskall = [];
for (let user of userList) {
if (user.ckStatus) {
taskall.push(await user.task_list());
await $.wait(3000); //延迟 1秒 可充分利用 $.环境函数
}
}
await Promise.all(taskall);
console.log('\n================== 执行任务 ==================\n');
taskall = [];
for (let user of userList) {
if (user.ckStatus) {
for (let num in user.taskList) {
if (user.taskList[num].taskStatus == 0) {
taskall.push(await user.task_do(user.taskList[num].taskCode));
} else {
console.log('当前任务已完成');
}
}
await $.wait(5000); //延迟 1秒 可充分利用 $.环境函数
}
}
await Promise.all(taskall);
}
class UserInfo {
constructor(str) {
this.index = ++userIdx;
this.ck = str.split('&')[0]; //单账号多变量分隔符
this.clientid = str.split('&')[1];
//let ck = str.split('&')
//this.data1 = ck[0]
this.ckStatus = true
this.taskList = '';
this.headersPost = {
'Host': 'mps.haiersmarthomes.com',
'accesstoken': this.ck,
'origin': 'https://zjrs.haier.net',
'user-agent': 'Mozilla/5.0 (Linux; U; Android 10; zh-CN; MI 8 Lite Build/QKQ1.190910.002) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/69.0.3497.100 UWS/3.22.2.55 Mobile Safari/537.36 UCBS/3.22.2.55_220929181439 ChannelId(1) NebulaSDK/1.8.100112 Nebula App/Uplus Nebula mPaaSClient',
'Content-Type': 'application/json;charset=UTF-8',
'accept': 'application/json, text/plain, */*',
'clientid': this.clientid,
'timestamp': ts13(),
'accounttoken': this.ck,
'appid': 'MB-UZHSH-0000',
'appkey': 'f50c76fbc8271d361e1f6b5973f54585',
'appversion': '7.19.0',
'referer': 'https://zjrs.haier.net/haierActivitys/intelligentHouse/index.html?container_type=3&hybrid_navbar_hidden=true&needAuthLogin=1&needLogin=1&needShare=1&checkGuestMode=1',
//'accept-encoding: 'gzip, deflate'
//'accept-language': 'zh-CN,en-US;q=0.9'
'x-requested-with': 'com.haier.uhome.uplus'
}
}
async task_userinfo() {//userinfo
try {
let options = {
url: `https://mps.haiersmarthomes.com/api-gw/wisdomHouseActivity/activity/index`,
headers: this.headersPost,
body: JSON.stringify({ "sourceClient": 1 })
}
//console.log(options);
let result = await httpRequest(options);
//console.log(result);
if (result.retCode == '00000') {
DoubleLog(`账号[${this.index}] ck验证成功: [${result.data.nickName}] 当前贝壳 [${result.data.wisdomStarBalance}] `);
this.ckStatus = true
} else {
DoubleLog(`账号[${this.index}] ck验证失效,原因未知!`);
this.ckStatus = false
console.log(result);
}
} catch (e) {
console.log(e);
}
}
async task_signin() {
try {
let options = {
url: `https://mps.haiersmarthomes.com/api-gw/wisdomHouseActivity/sign/signIn`,
headers: this.headersPost,
body: JSON.stringify({ "sourceClient": 1 })
}
//console.log(options);
let result = await httpRequest(options);
//console.log(result);
if (result.retCode == '00000') {
DoubleLog(`账号[${this.index}] 签到成功: 累计签到[${result.data.signDays}] `);
} else {
DoubleLog(`账号[${this.index}] 签到失效,原因未知!`);
console.log(result);
}
} catch (e) {
console.log(e);
}
}
async task_list() {//任务列表
try {
let options = {
url: `https://mps.haiersmarthomes.com/api-gw/wisdomHouseActivity/task/queryTask`,
headers: this.headersPost,
body: JSON.stringify({ "publishType": 2, "sourceClient": 1 })
}
//console.log(options);
let result = await httpRequest(options);
//console.log(result);
if (result.retCode == '00000') {
this.taskList = result.data.taskList
} else {
console.log(result);
}
} catch (e) {
console.log(e);
}
}
async task_do(taskCode) {//任务列表
try {
let options = {
url: `https://mps.haiersmarthomes.com/api-gw/wisdomHouseActivity/task/doTask`,
headers: this.headersPost,
body: JSON.stringify({ "taskCode": taskCode, "sourceClient": 1 })
}
//console.log(options);
let result = await httpRequest(options);
//console.log(result);
if (result.retCode == '00000') {
DoubleLog(`账号[${this.index}] 任务执行成功: [${taskCode}] `);
} else {
DoubleLog(`账号[${this.index}] 任务执行失效:,原因未知!`);
console.log(result);
}
} catch (e) {
console.log(e);
}
}
}
!(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 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();
}
})
})
}
function ts13() {
return Math.round(new Date().getTime()).toString();
}
// 双平台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(tLine truncated
-202
View File
@@ -1,202 +0,0 @@
/**
* new Env("HAPI哈啤硬核街")
* cron 20 17 * * * wx_hapi.js
* Show:
* 变量名:wx_hapi_cookie
* 变量值:bg-hardcore.ab-inbev.cn, Headers 中的 openid的值&sign的值&timestamp的值 3个值缺一不可
* scriptVersionNow = "0.0.2";
*/
const $ = new Env("HAPI哈啤硬核街");
const ckName = "wx_hapi_cookie";
const Notify = 1; //0为关闭通知,1为打开通知,默认为1
let envSplitor = ["@", "\n"]; //多账号分隔符
let strSplitor = '&'; //多变量分隔符
let scriptVersionNow = "0.0.2";
let jsUrl = "https://originfastly.jsdelivr.net/gh/smallfawn/QLScriptPublic@main/wx_hapi.js"
let noticeUrl = `https://originfastly.jsdelivr.net/gh/smallfawn/Note@main/Notice.json`
class UserInfo {
constructor(str) {
this.index = ++$.userIdx;
this.ck = str.split(strSplitor)[0]; //单账号多变量分隔符
this.sign = str.split(strSplitor)[1]
this.timestamp = str.split(strSplitor)[2]
this.ckStatus = true;
}
async main() {
await this.user_info()
}
creat_headers(){
return {
"Host": "bg-hardcore.ab-inbev.cn",
"Connection": "keep-alive",
"Content-Length": "35",
"charset": "utf-8",
"openid": this.ck,
"sign": this.sign,
"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/111.0.5563.116 Mobile Safari/537.36 XWEB/5261 MMWEBSDK/20230405 MMWEBID/2585 MicroMessenger/8.0.35.2360(0x2800235D) WeChat/arm64 Weixin NetType/WIFI Language/zh_CN ABI/arm64 MiniProgramEnv/android",
"content-type": "application/x-www-form-urlencoded",
"Accept-Encoding": "gzip,compress,br,deflate",
"timestamp": this.timestamp,
"Referer": "https://servicewechat.com/wx3235eff0af1e42d8/199/page-frame.html",
}
}
async sign_in() {
try {
let options = {
url: `https://bg-hardcore.ab-inbev.cn/api/checkin/dailyCheckIn`,
headers: this.creat_headers(),
body:`openId=${this.ck}`
},
result = await httpRequest(options);
//console.log(options);
console.log(JSON.stringify(result));
if (result.code == 0) {
$.DoubleLog(`✅账号[${this.index}] 签到成功[${result.data.point}]分🎉`);
} else {
$.DoubleLog(`❌账号[${this.index}] 签到失败`);
//console.log(result);
}
} catch (e) {
console.log(e);
}
}
//https://bg-hardcore.ab-inbev.cn/api/checkin/userIsCheckin
async check_signin() {
try {
let options = {
url: `https://bg-hardcore.ab-inbev.cn/api/checkin/userIsCheckin`,
headers: this.creat_headers(),
body:`openId=${this.ck}`
},
result = await httpRequest(options);
//console.log(options);
console.log(JSON.stringify(result));
if (result.code == !-1) {
await this.sign_in()
console.log(`签到 do`)
} else {
//console.log(result);
}
} catch (e) {
console.log(e);
}
}
//https://bg-hardcore.ab-inbev.cn/api/userCenter/getUserCenterInfo
async user_info() {
try {
let options = {
url: `https://bg-hardcore.ab-inbev.cn/api/userCenter/getUserCenterInfo`,
headers: this.creat_headers(),
body:`openId=${this.ck}`
},
result = await httpRequest(options);
//console.log(options);
console.log(JSON.stringify(result));
if (result.code == 0) {
$.DoubleLog(`✅账号[${this.index}] 欢迎[${result.data.username}]当前[${result.data.userPoints}]分 累计签到${result.data.joinDays}天🎉`);
await this.check_signin()
} else {
console.log(JSON.stringify(result));
}
} catch (e) {
console.log(e);
}
}
}
async function start() {
//await _getVersion(jsUrl);
//await _getNotice(noticeUrl);
let taskall = [];
for (let user of $.userList) {
if (user.ckStatus) {
taskall.push(await user.main());
}
}
await Promise.all(taskall);
}
!(async () => {
if (!(await checkEnv())) return;
if ($.userList.length > 0) {
await start();
} await $.SendMsg($.message);
})().catch((e) => console.log(e)).finally(() => $.done());
//********************************************************
/**
* 变量检查与处理
* @returns
*/
async function checkEnv() {
let userCookie = ($.isNode() ? process.env[ckName] : $.getdata(ckName)) || "";
//let userCount = 0;
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(`共找到${$.userList.length}个账号`), true; //true == !0
}
/////////////////////////////////////////////////////////////////////////////////////
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)
})
}
/**
* 获取远程版本
*/
async function _getVersion(jsUrl) {
const options = { url: jsUrl };
let httpResult = await httpRequest(options)
const regex = /scriptVersionNow\s*=\s*(["'`])([\d.]+)\1/;
const match = httpResult.match(regex);
const scriptVersionLatest = match ? match[2] : "";
$.DoubleLog(`\n====== 当前版本:${scriptVersionNow} 📌 最新版本:${scriptVersionLatest} ======`);
}
/**
* 获取远程通知
*/
async function _getNotice(noticeUrl) {
const options = { url: noticeUrl };
let httpResult = await httpRequest(options)
const notice = httpResult.notice.replace(/\\n/g, "\n");
$.DoubleLog(notice);
}
// ==================== 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.message = ""; 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 ? tLine truncated
//Env rewrite:smallfawn Update-time:23-07-26 newAdd:DoubleLog & SendMsg & ChangeMessage
-558
View File
@@ -1,558 +0,0 @@
/**
* cron 17 17 * * * 悦拜APP 左上角活动 金币换红包 实物
* 邀请码 OEJMUR 下载地址 微信打开 https://yuebuy.top/a.jDybfP
* 变量名:yuepaiToken
* 变量值:https://app.yuebuy.cn/api/checkin/userinfo Headers请求头中的x-auth-token的值 多账号&或换行或新建同名变量
* scriptVersionNow = "0.0.1";
*/
const $ = new Env("悦拜APP");
const notify = $.isNode() ? require('../sendNotify') : '';
let ckName = "yuepaiToken";
let envSplitor = ["&", "\n"]; //多账号分隔符
let strSplitor = "#"; //多变量分隔符
let userIdx = 0;
let userList = [];
class Task {
constructor(str) {
this.index = ++userIdx;
this.ck = str.split(strSplitor)[0]; //单账号多变量分隔符
this.ckStatus = true;
this.signStatus = false
}
async main() {
await this.task_usefinfo()
if (this.ckStatus) {
if (this.signStatus == false) {
await this.task_sign()
}
await this.task_index();
}
}
async taskRequest(method, url, body = "") {
//
function md5(str) {
const crypto = require('crypto');
return crypto.createHash('md5').update(str).digest('hex');
}
let timestamp = Date.now().toString()
let random = $.uuid()
let md5Str1 = md5(timestamp + random);
let sign = md5(md5Str1 + `YEqQJIyOzUABvTon`);
let headers = {
"push-token": "160a3797c901850e1fc",
"app": "4.2.9",
"system": "10",
"platform": "android",
"channelName": "xiaomi",
"model": "MI 8 Lite",
"x-auth-token": this.ck,
"x-auth-timestamp": timestamp,
"x-auth-random": random,
"x-auth-signature": sign,
"version": "v1",
"Content-Type": "application/x-www-form-urlencoded",
"Content-Length": "0",
"Host": "app.yuebuy.cn",
"Connection": "Keep-Alive",
"Accept-Encoding": "gzip",
"User-Agent": "okhttp/4.10.0"
}
const requestOptions = {
method: method,
headers: headers,
url: url
};
if (method !== "get") {
requestOptions.body = body;
}
const { body: result } = await $.httpRequest(requestOptions);
return result;
}
async task_usefinfo() {
let result = await this.taskRequest("post", `https://app.yuebuy.cn/api/checkin/userinfo`, `is_simple=0`)
//console.log(options);
//console.log(result);
if (result) {
if (result.code == 1) {
this.ckStatus = true
$.log(`ID [${result.data.user_id}]当前金币[${result.data.coin}] 今日是否签到[${result.data.today_is_checkin == 1}]`)
if (result.data.today_is_checkin == 1) {
this.signStatus = true
}
} else {
this.ckStatus = false
$.log(JSON.stringify(result));
}
}
}
async task_sign() {
let result = await this.taskRequest("post", `https://app.yuebuy.cn/api/checkin/checkin`, ``)
//console.log(options);
//console.log(result);
if (result) {
if (result.code == 0) {
$.log(result.message)
} else {
$.log(result.message);
}
}
}
async task_index() {
let result = await this.taskRequest("post", `https://app.yuebuy.cn/api/checkin/index`, ``)
//console.log(options);
//console.log(result);
if (result) {
if (result.code == 1) {
$.log(`获取任务列表` + result.message)
if (result.message == "Success") {
for (let index of result.data.task_data) {
if (index.title.indexOf("日常") != -1) {
for (let task of index.task_list) {
if (task.title.indexOf("浏览") != -1 || task.title.indexOf("分享") !== -1) {
$.log(`[${task.title}]任务状态[${task.is_finish == 1}]`)
if (task.is_finish == 0) {
$.log(`正在做任务[${task.title}]`)
await this.task_start(task.id)
}
}
}
}
}
}
} else {
$.log(JSON.stringify(result));
}
}
}
async task_start(id) {
let result = await this.taskRequest("post", `https://app.yuebuy.cn/api/checkin/getTask`, `task_id=${id}`)
//console.log(options);
//console.log(result);
if (result) {
if (result.code == 1) {
$.log(`任务开始` + result.message)
if (result.message == "Success") {
await $.wait(16000)
await this.task_finish(result.data.task_sn)
}
} else {
$.log(JSON.stringify(result));
}
}
//console.log(result.data);
}
async task_finish(sn) {
let result = await this.taskRequest("post", `https://app.yuebuy.cn/api/checkin/finishTask`, `task_sn=${sn}`)
//console.log(options);
//console.log(result);
if (result) {
if (result.code == 1) {
$.log(`任务完成` + result.message)
} else {
$.log(JSON.stringify(result));
}
}
//console.log(result.data);
}
}
async function start() {
let taskall = [];
for (let user of userList) {
if (user.ckStatus) {
taskall.push(await user.main());
}
}
await Promise.all(taskall);
}
!(async () => {
if (!(await checkEnv())) return;
if (userList.length > 0) {
await start();
}
await $.sendMsg($.logs.join("\n"))
})()
.catch((e) => console.log(e))
.finally(() => $.done());
//********************************************************
/**
* 变量检查与处理
* @returns
*/
async function checkEnv() {
let userCookie = ($.isNode() ? process.env[ckName] : $.getdata(ckName)) || "";
if (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 Task(n));
} else {
console.log("未找到CK");
return;
}
return console.log(`共找到${userList.length}个账号`), true; //true == !0
}
function Env(t, s) {
return new (class {
constructor(t, s) {
this.name = t;
this.data = null;
this.dataFile = "box.dat";
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;
}
isSurge() {
return "undefined" != typeof $httpClient && "undefined" == typeof $loon;
}
isLoon() {
return "undefined" != typeof $loon;
}
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),
s = this.path.resolve(process.cwd(), this.dataFile),
e = this.fs.existsSync(t),
i = !e && this.fs.existsSync(s);
if (!e && !i) return {};
{
const i = e ? t : s;
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),
s = this.path.resolve(process.cwd(), this.dataFile),
e = this.fs.existsSync(t),
i = !e && this.fs.existsSync(s),
o = JSON.stringify(this.data);
e ? this.writeFileSync(t, o) : i ? this.fs.writeFileSync(s, o) : this.fs.writeFileSync(t, o);
}
}
lodash_get(t, s, e) {
const i = s.replace(/\[(\d+)\]/g, ".$1").split(".");
let o = t;
for (const t of i) if (((o = Object(o)[t]), void 0 === o)) return e;
return o;
}
lodash_set(t, s, e) {
return Object(t) !== t
? t
: (Array.isArray(s) || (s = s.toString().match(/[^.[\]]+/g) || []),
(s
.slice(0, -1)
.reduce(
(t, e, i) =>
Object(t[e]) === t[e]
? t[e]
: (t[e] = Math.abs(s[i + 1]) >> 0 == +s[i + 1] ? [] : {}),
t
)[s[s.length - 1]] = e),
t);
}
getdata(t) {
let s = this.getval(t);
if (/^@/.test(t)) {
const [, e, i] = /^@(.*?)\.(.*?)$/.exec(t),
o = e ? this.getval(e) : "";
if (o)
try {
const t = JSON.parse(o);
s = t ? this.lodash_get(t, i, "") : s;
} catch (t) {
s = "";
}
}
return s;
}
setdata(t, s) {
let e = !1;
if (/^@/.test(s)) {
const [, i, o] = /^@(.*?)\.(.*?)$/.exec(s),
h = this.getval(i),
a = i ? ("null" === h ? null : h || "{}") : "{}";
try {
const s = JSON.parse(a);
this.lodash_set(s, o, t), (e = this.setval(JSON.stringify(s), i));
} catch (s) {
const h = {};
this.lodash_set(h, o, t), (e = this.setval(JSON.stringify(h), i));
}
} else e = this.setval(t, s);
return e;
}
getval(t) {
if (this.isSurge() || this.isLoon()) {
return $persistentStore.read(t);
} else if (this.isQuanX()) {
return $prefs.valueForKey(t);
} else if (this.isNode()) {
this.data = this.loaddata();
return this.data[t];
} else {
return this.data && this.data[t] || null;
}
}
setval(t, s) {
if (this.isSurge() || this.isLoon()) {
return $persistentStore.write(t, s);
} else if (this.isQuanX()) {
return $prefs.setValueForKey(t, s);
} else if (this.isNode()) {
this.data = this.loaddata();
this.data[s] = t;
this.writedata();
return true;
} else {
return this.data && this.data[s] || 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();
if (t) {
t.headers = t.headers ? t.headers : {};
if (typeof t.headers.Cookie === "undefined" && typeof t.cookieJar === "undefined") {
t.cookieJar = this.ckjar;
}
}
}
/**
* @param {Object} options
* @returns {String} 将 Object 对象 转换成 queryStr: key=val&name=senku
*/
queryStr(options) {
return Object.entries(options)
.map(([key, value]) => `${key}=${typeof value === 'object' ? JSON.stringify(value) : value}`)
.join('&');
}
//从url获取参数组成json
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] = decodeURIComponent(value);
});
}
return params;
}
isJSONString(str) {
try {
var obj = JSON.parse(str);
if (typeof obj == 'object' && obj) {
return true;
} else {
return false;
}
} 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 ($.isNode()) {
await notify.sendNotify($.name, message)
} else {
$.msg($.name, '', message)
}
}
async httpRequest(options) {
let t = {
...options
};
if (!t.headers) {
t.headers = {}
}
if (t.params) {
t.url += '?' + this.queryStr(t.params);
}
t.method = t.method.toLowerCase();
if (t.method === 'get') {
delete t.headers['Content-Type'];
delete t.headers['Content-Length'];
delete t.headers['content-type'];
delete t.headers['content-length'];
delete t["body"]
}
if (t.method === 'post') {
let ContentType;
if (!t.body) {
t.body = ""
} else {
if (typeof t.body == "string") {
if (this.isJSONString(t.body)) {
ContentType = 'application/json'
} else {
ContentType = 'application/x-www-form-urlencoded'
}
} else if (this.isJson(t.body)) {
t.body = JSON.stringify(t.body);
ContentType = 'application/json';
}
}
if (!t.headers['Content-Type']) {
t.headers['Content-Type'] = ContentType;
}
delete t.headers['Content-Length'];
}
if (this.isNode()) {
this.initGotEnv(t);
let httpResult = await this.got(t);
if (this.isJSONString(httpResult.body)) {
httpResult.body = JSON.parse(httpResult.body)
}
return httpResult;
}
if (this.isQuanX()) {
t.method = t.method.toUpperCase()
return new Promise((resolve, reject) => {
$task.fetch(t).then(response => {
if (this.isJSONString(response.body)) {
response.body = JSON.parse(response.body)
}
resolve(response)
})
})
}
}
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('');
}
timeStamp() {
return new Date().getTime()
}
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(s = t, e = "", i = "", o) {
const h = (t) =>
!t || (!this.isLoon() && this.isSurge())
? t
: "string" == typeof t
? this.isLoon()
? t
: this.isQuanX()
? { "open-url": t }
: void 0
: "object" == typeof t && (t["open-url"] || t["media-url"])
? this.isLoon()
? t["open-url"]
: this.isQuanX()
? t
: void 0
: void 0;
this.isMute ||
(this.isSurge() || this.isLoon()
? $notification.post(s, e, i, h(o))
: this.isQuanX() && $notify(s, e, i, h(o)));
let logs = ['', '==============📣系统通知📣=============='];
logs.push(t);
e ? logs.push(e) : '';
i ? logs.push(i) : '';
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.isSurge() && !this.isQuanX() && !this.isLoon();
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);
}
-438
View File
@@ -1,438 +0,0 @@
/**
* 悦野圈
* cron 7 8 * * * yyq.js
* 23/04/14 签到 点赞 评论 分享
* 23/11/26 删除 评论 分享 只做点赞和签到
* 24/03/24 修复脚本失效问题
* ========= 青龙--配置文件 ===========
* # 项目名称
* export yyq_new='Cookie#13111111 & Cookie#13111111'
* 变量名 yyq_new
* 抓包 https://customer.yueyequan.cn/ , 找到 headers中的 Cookie中 usersig的值#userid=后面的值
* 多账号&或换行 或新建同名变量
* 例如axxxxxxx#155511111
* ====================================
*
*/
const $ = new Env("悦野圈");
const ckName = "yyq_new";
//-------------------- 一般不动变量区域 -------------------------------------
const Notify = 1; //0为关闭通知,1为打开通知,默认为1
const notify = $.isNode() ? require('../sendNotify') : '';
let envSplitor = ["&", "\n"]; //多账号分隔符
let msg = ''; //let ck,msg
let userCookie = ($.isNode() ? process.env[ckName] : $.getdata(ckName)) || '';
let userList = [];
let userIdx = 0;
let userCount = 0;
//---------------------- 自定义变量区域 -----------------------------------
//---------------------------------------------------------
async function start() {
//await notice()
console.log('\n================== 用户信息 ==================\n');
taskall = [];
for (let user of userList) {
console.log(`随机延迟${user.getRandomTime()}ms`);
taskall.push(await user.user_info());
await $.wait(user.getRandomTime()); //延迟 1秒 可充分利用 $.环境函数
}
await Promise.all(taskall);
console.log('\n================== 签到 ==================\n');
taskall = [];
for (let user of userList) {
if (user.ckStatus) {
console.log(`随机延迟${user.getRandomTime()}ms`);
taskall.push(await user.task_signIn());
await $.wait(user.getRandomTime());
}
}
await Promise.all(taskall);
//获取文章
for (let user of userList) {
if (user.ckStatus) {
taskall.push(await user.get_list());
await $.wait(user.getRandomTime());
}
//console.log(user.articleIdArr);
}
console.log('\n================== 点赞 ==================\n');
taskall = [];
for (let user of userList) {
if (user.ckStatus) {
console.log(`随机延迟${user.getRandomTime()}ms`);
for (let o = 0; o < 5; o++) {
taskall.push(await user.task_like(user.articleIdArr[o]));
await $.wait(user.getRandomTime());
}
}
}
await Promise.all(taskall);
/*console.log('\n================== 评论 ==================\n');
taskall = [];
for (let user of userList) {
if (user.ckStatus) {
console.log(`随机延迟${user.getRandomTime()}ms`);
for (let o = 0; o < 5; o++) {
taskall.push(await user.task_add(user.articleIdArr[o]));
await $.wait(user.getRandomTime());
}
}
}
await Promise.all(taskall);*/
/*console.log('\n================== 分享 ==================\n');
taskall = [];
for (let user of userList) {
if (user.ckStatus) {
console.log(`随机延迟${user.getRandomTime()}ms`);
for (let o = 0; o < 5; o++) {
taskall.push(await user.task_share(user.articleIdArr[o]));
await $.wait(user.getRandomTime());
}
}
}
await Promise.all(taskall);*/
}
class UserInfo {
constructor(str) {
this.index = ++userIdx;
this.ck = str.split('#')[0]; //单账号多变量分隔符
//this.data1 = ck[0]
this.ckStatus = true
//this.userId = this.ck.match(/userid=(\S*);Path=\/;usersig=/)[1];
this.userId = str.split('#')[1]; //单账号多变量分隔符;
this.headers = {
"User-Agent": "okhttp/4.2.0 (Android 10; Xiaomi MI 8 Lite Build/V11.0.2.0.QDTCNXM 2.12.0 21200 release baic-orv-app-android baicorvApp baic-orv-app-android)",
"appInfo": "{\"appVersion\":\"2.12.0\",\"osVersion\":\"Android 10\",\"appType\":\"Android\",\"deviceId\":\"76a9d22fc49aac9af4a7575488935928@1711269006040\",\"deviceName\":\"Xiaomi MI 8 Lite\"}",
"appTheme": "AQUA",
"Cookie": `userid=${this.userId};usersig=${this.ck};`,
"Cache-Control": "no-cache",
"Accept-Encoding": "identity",
"ice-auth-appkey": 9687643962,
}
this.articleIdArr = []
}
getRandomTime() {
return randomInt(3000, 9000)
}
getSign(method, path, timestamp, data) {
let baseData
if (typeof data == 'object' && data !== null) {
data = "json=" + JSON.stringify(data)
} else {
data = data.toLowerCase()
}
if (method == 'GET') {
baseData = `${method}${path}ice-auth-appkey:9687643962ice-auth-timestamp:${timestamp}${data}9ee70cb717f382417d1404fca6df80fd`
} else {
baseData = `${method}${path}ice-auth-appkey:9687643962ice-auth-timestamp:${timestamp}${data}9ee70cb717f382417d1404fca6df80fd`
}
baseData = encodeURIComponent(baseData)
//console.log(baseData);
return SHA256_Encrypt(baseData)
}
async user_info() {
try {
let options = {
url: `https://customer.yueyequan.cn/comu-core/v1.0/common/app/user/getMe?userId=${this.userId}`,
headers: this.headers
}
options.headers['ice-auth-timestamp'] = ts13()
options.headers['ice-auth-sign'] = this.getSign('GET', '/comu-core/v1.0/common/app/user/getMe', ts13(), `userId=${this.userId}`)
//console.log(options);
let result = await httpRequest(options);
//console.log(result);
if (result.code == 200) {
DoubleLog(`账号[${this.index}] 欢迎用户: ${result.data.nickName}`);
this.ckStatus = true
} else {
DoubleLog(`账号[${this.index}] 用户查询:失败 ❌ 了呢,原因未知!`);
this.ckStatus = false
console.log(result);
}
} catch (e) {
console.log(e);
}
}
async task_signIn() {
try {
let options = {
url: `https://customer.yueyequan.cn/comu-mem/member/v1.0/common/app/user/signIn`,
headers: this.headers,
body: `userId=${this.userId}`
}
options.headers['Content-Type'] = 'application/x-www-form-urlencoded'
options.headers['ice-auth-timestamp'] = ts13()
options.headers['ice-auth-sign'] = this.getSign('POST', '/comu-mem/member/v1.0/common/app/user/signIn', ts13(), `userId=${this.userId}`)
//console.log(options);
let result = await httpRequest(options);
//console.log(result);
if (result.code == 200) {
DoubleLog(`账号[${this.index}] 签到: [${result.msg}]`);
} else {
DoubleLog(`账号[${this.index}] 签到:失败 ❌ 了呢,原因未知!`);
console.log(result);
}
} catch (e) {
console.log(e);
}
}
async get_list() {
try {
let options = {
url: `https://customer.yueyequan.cn/comu-core/v1/app/newPopular?pageSize=20&pageNum=1`,
headers: this.headers
}
options.headers['ice-auth-timestamp'] = ts13()
options.headers['ice-auth-sign'] = this.getSign('GET', '/comu-core/v1/app/newPopular', ts13(), 'pageSize=20pageNum=1')
//console.log(options);
let result = await httpRequest(options);
//console.log(result);
if (result.code == 200) {
for (let i = 0; i < 20; i++) {
this.articleIdArr.push(result.data.records[i].entity.id)
}
} else {
console.log(`获取文章失败`);
console.log(result);
}
} catch (e) {
console.log(e);
}
}
async task_like(articleId) {
try {
let options = {
url: `https://customer.yueyequan.cn/comu-core/v1.0/creation/like`,
headers: this.headers,
body: JSON.stringify({ "entityId": `${articleId}`, "entityType": "002", "userId": `${this.userId}` })
}
options.headers['Content-Type'] = 'application/json;charset=UTF-8'
options.headers['ice-auth-timestamp'] = ts13()
options.headers['ice-auth-sign'] = this.getSign('POST', '/comu-core/v1.0/creation/like', ts13(), { "entityId": articleId, "entityType": "002", "userId": this.userId })
//console.log(options);
let result = await httpRequest(options);
//console.log(result);
if (result.code == 200) {
DoubleLog(`账号[${this.index}] 点赞: [${result.msg}] [${articleId}]`);
} else {
DoubleLog(`账号[${this.index}] 点赞:失败 ❌ 了呢,原因未知!`);
console.log(result);
}
} catch (e) {
console.log(e);
}
}
async task_add(articleId) {
try {
let txt = await hitokoto()
let options = {
url: `https://customer.yueyequan.cn/comu-core/v1.0/comment/addComment`,
headers: this.headers,
body: JSON.stringify({ "content": "" + txt + "" + + "", "parentId": "0", "targetName": "", "entityId": `${articleId}`, "entityType": "002", "source": "" })
}
options.headers['Content-Type'] = 'application/json;charset=UTF-8'
options.headers['ice-auth-timestamp'] = ts13()
options.headers['ice-auth-sign'] = this.getSign('POST', '/comu-core/v1.0/comment/addComment', ts13(), `{"content":"加油","parentId":"0","targetName":"","entityId":${articleId},"entityType":"002","source":""}`)
//console.log(options);
let result = await httpRequest(options);
//console.log(result);
if (result.code == 200) {
DoubleLog(`账号[${this.index}] 评论:[${result.msg}] [${articleId}]`);
} else {
DoubleLog(`账号[${this.index}] 评论:失败 ❌ 了呢,原因未知!`); console.log(result);
}
} catch (e) {
console.log(e);
}
}
async task_share(articleId) {
try {
let options = {
url: `https://customer.yueyequan.cn/comu-mem/member/v2/share`,
headers: this.headers,
body: JSON.stringify({ "id": `${articleId}`, "type": "4" })
}
options.headers['Content-Type'] = 'application/json;charset=UTF-8'
options.headers['ice-auth-timestamp'] = ts13()
options.headers['ice-auth-sign'] = this.getSign('POST', '/comu-mem/member/v2/share', ts13(), `{"id":${articleId},"type":"4"}`)
//console.log(options);
let result = await httpRequest(options);
//console.log(result);
if (result.code == 200) {
DoubleLog(`账号[${this.index}] 分享:[${result.msg}] [${articleId}]`);
} else {
DoubleLog(`账号[${this.index}] 分享:失败 ❌ 了呢,原因未知!`); console.log(result);
}
} catch (e) {
console.log(e);
}
}
}
!(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 httpRequest(options, method) {
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}请求失败`);
$.logErr(err);
//throw new Error(err);
//console.log(err);
} else {
//httpResult = data;
//httpResponse = resp;
if (data) {
//console.log(data);
typeof JSON.parse(data) == 'object' ? data = JSON.parse(data) : data = data
resolve(data)
} else {
console.log(`请求api返回数据为空,请检查自身原因`)
}
}
} catch (e) {
//console.log(e, resp);
$.logErr(e, resp);
} finally {
resolve();
}
})
})
}
/**
* 时间戳 13位
*/
function ts13() {
return Math.round(new Date().getTime()).toString();
}
function randomInt(min, max) {
return Math.round(Math.random() * (max - min) + min);
}
async function notice() {
try {
let options = {
url: `https://ghproxy.com/https://raw.githubusercontent.com/smallfawn/api/main/notice.json`,
headers: {
'User-Agent': ''
},
}
//console.log(options);
let result = await httpRequest(options);
//console.log(result);
if (result) {
if ('notice' in result) {
DoubleLog(`${result.notice}`);
} else {
options.url = `https://gitee.com/smallfawn/api/raw/master/notice.json`
result = await httpRequest(options);
if ('notice' in result) {
DoubleLog(`${result.notice}`);
}
}
} else {
}
} catch (e) {
console.log(e);
}
}
async function hitokoto() { // 随机一言
try {
let options = {
url: 'https://v1.hitokoto.cn/',
headers: {}
};
//console.log(options);
let result = await httpRequest(options);
//console.log(result);
return result.hitokoto
} catch (error) {
console.log(error);
}
}
// 双平台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()) {
await notify.sendNotify($.name, message)
} else {
$.msg($.name, '', message)
}
} else {
console.log(message)
}
}
/**
* SHA256 加密
*/
function SHA256_Encrypt(data) {
sha256_init();
sha256_update(data, data.length);
sha256_final();
return sha256_encode_hex();
}
/* SHA256 logical functions */ function rotateRight(n, x) { return (x >>> n) | (x << (32 - n)); } function choice(x, y, z) { return (x & y) ^ (~x & z); } function majority(x, y, z) { return (x & y) ^ (x & z) ^ (y & z); } function sha256_Sigma0(x) { return rotateRight(2, x) ^ rotateRight(13, x) ^ rotateRight(22, x); } function sha256_Sigma1(x) { return rotateRight(6, x) ^ rotateRight(11, x) ^ rotateRight(25, x); } function sha256_sigma0(x) { return rotateRight(7, x) ^ rotateRight(18, x) ^ (x >>> 3); } function sha256_sigma1(x) { return rotateRight(17, x) ^ rotateRight(19, x) ^ (x >>> 10); } function sha256_expand(W, j) { return (W[j & 0x0f] += sha256_sigma1(W[(j + 14) & 0x0f]) + W[(j + 9) & 0x0f] + sha256_sigma0(W[(j + 1) & 0x0f])); } /* Hash constant words K: */ var K256 = new Array(0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2); /* global arrays */ var ihash, count, buffer; var sha256_hex_digits = "0123456789abcdef"; /* Add 32-bit integers with 16-bit operations (bug in some JS-interpreters: overflow) */ function safe_add(x, y) { var lsw = (x & 0xffff) + (y & 0xffff); var msw = (x >> 16) + (y >> 16) + (lsw >> 16); return (msw << 16) | (lsw & 0xffff); } /* Initialise the SHA256 computation */ function sha256_init() { ihash = new Array(8); count = new Array(2); buffer = new Array(64); count[0] = count[1] = 0; ihash[0] = 0x6a09e667; ihash[1] = 0xbb67ae85; ihash[2] = 0x3c6ef372; ihash[3] = 0xa54ff53a; ihash[4] = 0x510e527f; ihash[5] = 0x9b05688c; ihash[6] = 0x1f83d9ab; ihash[7] = 0x5be0cd19; } /* Transform a 512-bit message block */ function sha256_transform() { var a, b, c, d, e, f, g, h, T1, T2; var W = new Array(16); /* Initialize registers with the previous intermediate value */ a = ihash[0]; b = ihash[1]; c = ihash[2]; d = ihash[3]; e = ihash[4]; f = ihash[5]; g = ihash[6]; h = ihash[7]; /* make 32-bit words */ for (var i = 0; i < 16; i++) W[i] = buffer[(i << 2) + 3] | (buffer[(i << 2) + 2] << 8) | (buffer[(i << 2) + 1] << 16) | (buffer[i << 2] << 24); for (var j = 0; j < 64; j++) { T1 = h + sha256_Sigma1(e) + choice(e, f, g) + K256[j]; if (j < 16) T1 += W[j]; else T1 += sha256_expand(W, j); T2 = sha256_Sigma0(a) + majority(a, b, c); h = g; g = f; f = e; e = safe_add(d, T1); d = c; c = b; b = a; a = safe_add(T1, T2); } /* Compute the current intermediate hash value */ ihash[0] += a; ihash[1] += b; ihash[2] += c; ihash[3] += d; ihash[4] += e; ihash[5] += f; ihash[6] += g; ihash[7] += h; } /* Read the next chunk of data and update the SHA256 computation */ function sha256_update(data, inputLen) { var i, index, curpos = 0; /* Compute number of bytes mod 64 */ index = (count[0] >> 3) & 0x3f; var remainder = inputLen & 0x3f; /* Update number of bits */ if ((count[0] += inputLen << 3) < inputLen << 3) count[1]++; count[1] += inputLen >> 29; /* Transform as many times as possible */ for (i = 0; i + 63 < inputLen; i += 64) { for (var j = index; j < 64; j++) buffer[j] = data.charCodeAt(curpos++); sha256_transform(); index = 0; } /* Buffer remaining input */ for (var j = 0; j < remainder; j++) buffer[j] = data.charCodeAt(curpos++); } /* Finish the computation by operations such as padding */ function sha256_final() { var index = (count[0] >> 3) & 0x3f; buffer[index++] = 0x80; if (index <= 56) { for (var i = index; i < 56; i++) buffer[i] = 0; } else { for (var i = index; i < 64; i++) buffer[i] = 0; sha256_transform(); for (var i = 0; i < 56; i++) buffer[i] = 0; } buffer[56] = (count[1] >>> 24) & 0xff; buffer[57] = (count[1] >>> 16) & 0xff; buffer[58] = (count[1] >>> 8) & 0xff; buffer[59] = count[1] & 0xff; buffer[60] = (count[0] >>> 24) & 0xff; buffer[61] = (count[0] >>> 16) & 0xff; buffer[62] = (count[0] >>> 8) & 0xff; buffer[63] = count[0] & 0xff; sha256_transform(); } /* Split the internal hash values into an array of bytes */ function sha256_encode_bytes() { var j = 0; var output = new Array(32); for (var i = 0; i < 8; i++) { output[j++] = (ihash[i] >>> 24) & 0xff; output[j++] = (ihash[i] >>> 16) & 0xff; output[j++] = (ihash[i] >>> 8) & 0xff; output[j++] = ihash[i] & 0xff; } return output; } /* Get the internal hash as a hex string */ function sha256_encode_hex() { var output = new String(); for (var i = 0; i < 8; i++) { for (var j = 28; j >= 0; j -= 4) output += sha256_hex_digits.charAt((ihash[i] >>> j)Line truncated
// 完整 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(tLine truncated
-269
View File
@@ -1,269 +0,0 @@
/**
* 植物星球
* cron "30 9 * * *" zwxq.js
* 注册:https://www.pftp2012.com
* export zwxq= 账号&密码 多账号换行或者#分隔
*/
// ============================================================================================================
const $ = new Env('植物星球')
const axios = require('axios')
const md5 = require('md5')
const env_name = 'zwxq' //环境变量名字
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 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 userName = ck_info[0]
let userPwd = ck_info[1]
let user = {
index: index,
userName,
userPwd,
}
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}]开始任务 =============`)
let ck = await Login(user)
await wait(1)
//console.log(ck);
await Sign(user, ck)
await wait(1)
await mission(user, '10', ck)
await wait(1)
await mission(user, '60', ck)
}
// =============================================================================================================================
//登入
async function Login(user) {
try {
let userPwd = md5(user.userPwd);
let urlObject = {
method: 'post',
url: `https://api.pftp2012.com/api/Member/Login`,
headers: {
'Host': 'api.pftp2012.com',
'Content-Type': 'application/x-www-form-urlencoded',
'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: {
userName: user.userName,
userPwd: userPwd,
keepAlive: true,
channel: 10,
}
};
//console.log(urlObject);
let { data: result } = await axios.request(urlObject)
//let Token = result.Data.MemberInfo.Token;
//console.log(result);
if (result?.Data) {
//打印签到结果
DoubleLog(`🌸账号[${result.Data.MemberInfo.MemberName}]` + `🕊登入成功-当前[${result.Data.MemberInfo.MemberPollen}]积分🎉`);
} else {
DoubleLog(`🌸账号[${user.index}]登入-失败:${result.Msg}❌`)
}
return result.Data.MemberInfo.Token;
} catch (e) {
//打印错误信息
console.log('以下是报错输出:');
console.log(e);
}
}
//签到
async function Sign(user, Token) {
try {
let urlObject = {
method: 'get',
url: `https://api.pftp2012.com/api/Member/SignIn?channel=10`,
headers: {
'Host': 'api.pftp2012.com',
'Content-Type': 'application/x-www-form-urlencoded',
'Authorization': 'Bearer' + ' ' + Token,
'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',
},
}
//
let { data: result } = await axios.request(urlObject)
//console.log(urlObject);
//console.log(result);
if (result.Status == 100) {
//打印签到结果
DoubleLog(`🌸账号[${user.index}]🕊签到成功-获得${result.Data.PollenNum}积分-连续签到${result.Data.ContinuouNum}天🎉`);
} else {
DoubleLog(`🌸账号[${user.index}]🕊签到:${result.Msg}❌`)
}
} catch (e) {
//打印错误信息
console.log(e);
}
}
//任务
async function mission(user, id, Token) {
try {
let urlObject = {
method: 'post',
url: `https://api.pftp2012.com/api/Member/CompleteMemberMission`,
headers: {
'Host': 'api.pftp2012.com',
'Content-Type': 'application/x-www-form-urlencoded',
'Authorization': 'Bearer' + ' ' + Token,
'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: {
type: id,
channel: 40,
}
}
//
let { data: result } = await axios.request(urlObject)
//console.log(urlObject);
//console.log(result);
if (result?.Status == '100') {
//打印签到结果
DoubleLog(`🌸账号[${user.index}]` + `🕊浏览任务id:${id}成功,获得${result.Data}积分🎉`);
} else {
DoubleLog(`🌸账号[${user.index}]浏览任务失败:${result.Msg}❌`)
}
} catch (e) {
//打印错误信息
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 = [
"https://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);
}
}
//================================================固定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]) ||Line truncated
//Env rewrite:smallfawn Update-time:24-08-09 newAdd:DoubleLog & SendMsg
-243
View File
@@ -1,243 +0,0 @@
/**
* new Env("掌上天津极速版")
* cron 5 15 * * * zstjjsb.js
* Show:
* 变量名:zstjjsb_data
* 变量值:http://bbs.zaitianjin.net/zstj/v2.8/index.php 请求body(txt)中 => userId的值&salf的值
* scriptVersionNow = "0.0.1";
*/
const $ = new Env("掌上天津极速版");
const ckName = "zstjjsb_data";
const Notify = 1; //0为关闭通知,1为打开通知,默认为1
let envSplitor = ["@", "\n"]; //多账号分隔符
let strSplitor = '&'; //多变量分隔符
const CryptoJS = require("crypto-js")
let scriptVersionNow = "0.0.1";
let msg = "";
async function start() {
//await getVersion("smallfawn/QLScriptPublic@main/zstjjsb.js");
//await getNotice();
let taskall = [];
for (let user of $.userList) {
if (user.ckStatus) {
taskall.push(await user.task());
$.DoubleLog(`等待10s`)
await $.wait(10000);
}
}
await Promise.all(taskall);
}
class UserInfo {
constructor(str) {
this.index = ++$.userIdx;
this.userId = str.split(strSplitor)[0]; //单账号多变量分隔符
this.salf = str.split(strSplitor)[1];
this.ckStatus = true;
}
async task() {
$.DoubleLog(`------ 第[${this.index}]个账号 ------`)
await this.sign_info()
}
encode(str) {
//var b = new Buffer(str);
var b = Buffer.from(str);
var s = b.toString('base64');
var s = s.replace(/\//g, '_')
return s
}
getmac() {
var mac = "";
for (var i = 0; i < 6; i++) {
var randomByte = Math.floor(Math.random() * 256);
var hexString = randomByte.toString(16).toUpperCase();
mac += (hexString.length === 1 ? "0" + hexString : hexString) + ":";
}
mac = mac.slice(0, -1); // 去掉最后一个冒号
return mac;
}
async sign_info() {
let timestamp = Math.round(new Date().getTime() / 1000).toString();
let macs = this.getmac()
let mac = encodeURIComponent(macs)
let s = 'brand=OPPO&client=android&deviceInfo=OPPO_PCAM00_2021040100_10&interfaceVersion=v2.8&lat=30.1&lng=114.2&mac=' + macs + '&model=PCAM00&privacyStatus=1&region=天津市&salf=' + this.salf + '&timestamp=' + timestamp + '&uid=' + this.userId + '&userId=' + this.userId + '&version=2.8.4&versionCode=154'
s = this.encode(s)
let signs = CryptoJS.HmacSHA1(s, '1s_vsegymTasdgKxiKvRz5vDlyzmc92A_H6A8zg6I').toString().toUpperCase()
try {
let options = {
method: 'POST',
url: 'http://bbs.zaitianjin.net/zstj/v2.8/index.php',
headers: {
'Content-Yype': 'application/x-www-form-urlencoded',
'Host': 'bbs.zaitianjin.net',
'Connection': 'Keep-Alive',
'Accept-Encoding': 'gzip',
'User-Agent': 'okhttp/4.9.3'
},
body: 'c=User&lng=114.2&privacyStatus=1&sign=' + signs + '&interfaceVersion=v2.8&version=2.8.4&userId=' + this.userId + '&m=signInfo&mac=' + mac + '&versionCode=154&deviceInfo=OPPO_PCAM00_2021040100_10&uid=' + this.userId + '&client=android&model=PCAM00&region=%E5%A4%A9%E6%B4%A5%E5%B8%82&salf=' + this.salf + '&brand=OPPO&lat=30.1&timestamp=' + timestamp
}, result = await httpRequest(options);
//console.log(options);
//console.log(result);
if (result["code"] == 1) {
$.DoubleLog(`账号[${this.index}] 签到天数: ${result["data"]["signDays"]}🎉`);
$.DoubleLog(`账号[${this.index}] 累计签到天数: ${result["data"]["signAllDays"]}`)
$.DoubleLog(`账号[${this.index}] 今日是否签到: ${result["data"]["signStatue"]}`)
$.DoubleLog(`账号[${this.index}] 连续签到7天奖励: ${result["data"]["signData"]}`)
if (result["data"]["signStatue"] == false) {
await this.sign()
}
} else {
$.DoubleLog(`账号[${this.index}] 失败 ❌`);
//console.log(options);
//console.log(result);
}
} catch (e) {
console.log(e);
}
}
async sign() {
let timestamp = Math.round(new Date().getTime() / 1000).toString();
let macs = this.getmac()
let mac = encodeURIComponent(macs)
let s = 'brand=OPPO&client=android&deviceInfo=OPPO_PCAM00_2021040100_10&interfaceVersion=v2.8&lat=30.1&lng=114.2&mac=' + macs + '&model=PCAM00&privacyStatus=1&region=天津市&salf=' + this.salf + '&timestamp=' + timestamp + '&uid=' + this.userId + '&userId=' + this.userId + '&version=2.8.4&versionCode=154'
s = this.encode(s)
let signs = CryptoJS.HmacSHA1(s, '1s_vsegymTasdgKxiKvRz5vDlyzmc92A_H6A8zg6I').toString().toUpperCase()
try {
let options = {
method: 'POST',
url: 'http://bbs.zaitianjin.net/zstj/v2.8/index.php',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Host': 'bbs.zaitianjin.net',
'Connection': 'Keep-Alive',
'Accept-Encoding': 'gzip',
'User-Agent': 'okhttp/4.9.3'
},
body: 'c=Credit&lng=114.2&privacyStatus=1&sign=' + signs + '&interfaceVersion=v2.8&version=2.8.4&userId=' + this.userId + '&m=sign&mac=' + mac + '&versionCode=154&deviceInfo=OPPO_PCAM00_2021040100_10&uid=' + this.userId + '&client=android&model=PCAM00&region=%E5%A4%A9%E6%B4%A5%E5%B8%82&salf=' + this.salf + '&brand=OPPO&lat=30.1&timestamp=' + timestamp
}, result = await httpRequest(options);
//console.log(options);
//console.log(result);
if (result["code"] == 1) {
$.DoubleLog(`账号[${this.index}] 签到成功🎉`);
} else {
$.DoubleLog(`账号[${this.index}] 签到:失败 ❌ `);
//console.log(options);
//console.log(result);
}
} catch (e) {
console.log(e);
}
}
}
!(async () => {
if (!(await checkEnv())) return;
if ($.userList.length > 0) {
await start();
} await $.SendMsg(msg);
})().catch((e) => console.log(e)).finally(() => $.done());
//********************************************************
/**
* 变量检查与处理
* @returns
*/
async function checkEnv() {
let userCookie = ($.isNode() ? process.env[ckName] : $.getdata(ckName)) || "";
//let userCount = 0;
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(`共找到${$.userList.length}个账号`), true; //true == !0
}
/////////////////////////////////////////////////////////////////////////////////////
function httpRequest(options, method = null) {
method = options.method ? options.method.toLowerCase() : options.body ? "post" : "get";
return new Promise((resolve) => {
$[method](options, (err, resp, data) => {
if (err) {
//console.log(resp)
console.log(`${method}请求失败`);
$.logErr(err);
} else {
//console.log(resp)
//console.log(data)
if (data) {
try { data = JSON.parse(data); } catch (error) { }
resolve(data);
} else {
console.log(`请求api返回数据为空,请检查自身原因`);
}
}
resolve();
});
});
}
/**
* 获取远程版本
*/
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);
});
}
/**
* 获取远程通知
*/
async function getNotice() {
try {
const urls = [
"https://fastly.jsdelivr.net/gh/smallfawn/Note@main/Notice.json",
"https://gcore.jsdelivr.net/gh/smallfawn/Note@main/Notice.json",
"https://cdn.jsdelivr.net/gh/smallfawn/Note@main/Notice.json",
"https://ghproxy.com/https://raw.githubusercontent.com/smallfawn/Note/main/Notice.json",
"https://ghproxy.net/https://raw.githubusercontent.com/smallfawn/Note/refs/heads/main/Notice.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);
}
}
// ==================== 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]) ||Line truncated
//Env rewrite:smallfawn Update-time:23-6-30 newAdd:DoubleLog & SendMsg
+1
View File
@@ -3,6 +3,7 @@
# 作者: 青龙面板适配
# 说明: 360社区自动签到脚本(青龙面板专用)
# 依赖: requests
# new Env("360社区签到")
# 用法: 在青龙面板环境变量中设置 BBS360_COOKIE
# 请确保Cookie包含 __cfduid, uid 等必要字段
+136
View File
@@ -0,0 +1,136 @@
/*
------------------------------------------
@Author: sm
@Date: 2024.06.07 19:15
@Description: 海尔智家
cron: 30 7 * * *
------------------------------------------
#Notice:
变量名hrzj
抓取https://zjrs.haier.net请求头accounttoken 多账户&或换行
⚠️【免责声明】
------------------------------------------
1、此脚本仅用于学习研究,不保证其合法性、准确性、有效性,请根据情况自行判断,本人对此不承担任何保证责任。
2、由于此脚本仅用于学习研究,您必须在下载后 24 小时内将所有内容从您的计算机或手机或任何存储设备中完全删除,若违反规定引起任何事件本人对此均不负责。
3、请勿将此脚本用于任何商业或非法目的,若违反规定请自行对此负责。
4、此脚本涉及应用与本人无关,本人对因此引起的任何隐私泄漏或其他后果不承担任何责任。
5、本人对任何脚本引发的问题概不负责,包括但不限于由脚本错误引起的任何损失和损害。
6、如果任何单位或个人认为此脚本可能涉嫌侵犯其权利,应及时通知并提供身份证明,所有权证明,我们将在收到认证文件确认后删除此脚本。
7、所有直接或间接使用、查看此脚本的人均应该仔细阅读此声明。本人保留随时更改或补充此声明的权利。一旦您使用或复制了此脚本,即视为您已接受此免责声明。
*/
const { Env } = require("./tools/env")
const $ = new Env("海尔智家");
let ckName = `hezj`;
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 request(options) {
let baseHeaers = {
"host": "zj.haier.net",
"content-type": "application/json",
"accounttoken": this.token,
"appid": "MB-UZHSH-0001",
"accept": "*/*",
"sec-fetch-site": "same-site",
"appversion": "10.18.0",
//"clientid": "5D6FD623-11A7-4B62-88AD-D3D62D07B72F",
"accept-language": "zh-CN,zh-Hans;q=0.9",
"accept-encoding": "gzip, deflate, br",
"sec-fetch-mode": "cors",
"origin": "https://zjrs.haier.net",
"user-agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 16_7_15 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Hainer/Haier Simulation/Nebula App/Uplus Nebula mPaaSClient",
"referer": "https://zjrs.haier.net/",
"sec-fetch-dest": "empty"
}
options.headers = Object.assign(baseHeaers, options.headers)
return await axios.request(options)
}
async run() {
await this.pointInfo()
await this.signIn()
}
async pointInfo() {
let options = {
method: 'POST',
url: `https://zj.haier.net/zjapi/zjBaseServer/signDetail/getUserPointsAndWallet`,
headers: {},
data: {
}
};
let { data: result } = await this.request(options);
if (result.retCode == '00000') {
$.log(`海贝:${result.data.haiBeiTotal}`)
$.log(`红包:${result.data.wallet}`)
} else {
$.log(`查询余额失败: ${result.retInfo}`)
}
}
async signIn() {
let options = {
method: 'POST',
url: `https://zj.haier.net/api-gw/zjBaseServer/daily/sign`,
headers: {},
data: {
}
};
let { data: result } = await this.request(options);
if (result?.retCode == '00000') {
//打印签到结果
$.log(`🌸账号[${this.index}]` + `🕊当前已签到${result.data.totalSignDay}天🎉`);
} else {
$.log(`🌸账号[${this.index}] 签到-失败:${result.retInfo}❌`)
}
}
}
!(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
}
-13
View File
@@ -1,13 +0,0 @@
module.exports = {
getBucket,
updateBucket
}
const fs = require('fs')
function getBucket(bucketName) {
return fs.readFileSync(bucketName)
}
function updateBucket(bucketName, bucket) {
return fs.writeFileSync(bucketName, bucket)
}