🎯 方案概览
| 组件 | 作用 |
|---|
| 油猴脚本 | 打开 https://juzi52.net/user 时自动点击签到 |
| Windows 定时任务 | 每天 7:51 自动打开浏览器执行签到 |
| 订阅流量查询脚本 | 查询桔子云订阅的流量使用情况和到期时间 |
🖥️ 油猴脚本
代码
(function () {
"use strict";
function waitForElement(selector, timeout = 20000) {
return new Promise((resolve) => {
const start = Date.now();
const check = () => {
const el = document.querySelector(selector);
if (el) {
resolve(el);
} else if (Date.now() - start > timeout) {
resolve(null);
} else {
setTimeout(check, 300);
}
};
check();
});
}
async function main() {
const btn = await waitForElement("#checkin-div a");
if (!btn) {
console.warn("⚠️ 未找到签到按钮,请检查页面结构");
return;
}
const text = btn.textContent.trim();
if (text.includes("已签到") || text.includes("已签")) {
console.log("✅ 今日已签到,无需操作");
return;
}
if (text.includes("每日签到")) {
console.log("🔍 准备签到...");
if (typeof checkin === "function") {
checkin();
console.log("✅ 已调用 checkin() 函数签到成功");
} else {
btn.click();
console.log("✅ 已模拟点击按钮");
}
} else {
console.log("ℹ️ 按钮文本为:" + text + ',未匹配到"每日签到",请检查');
}
}
if (document.readyState === "complete") {
main();
} else {
window.addEventListener("load", main);
}
})();
脚本逻辑说明
| 步骤 | 说明 |
|---|
| ① 定位按钮 | 通过 #checkin-div a 精准定位签到链接 |
| ② 状态检测 | 若按钮文字含"已签到"则直接退出,避免重复 |
| ③ 执行签到 | 优先调用全局 checkin() 函数,失败则回退到模拟点击 |
⏰ Windows 定时任务
创建命令(管理员CMD执行)
schtasks /create /tn "桔子网签到" /tr "\"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe\" https://juzi52.net/user" /sc daily /st 07:51:00 /ru "hx\18421"
参数说明
| 参数 | 含义 |
|---|
/tn | 任务名称:桔子网签到 |
/tr | 执行命令:打开 Edge 并访问签到页 |
/sc daily | 每天重复 |
/st 07:51:00 | 开始时间(24小时制) |
/ru "hx\18421" | 以该用户身份运行 |
常用管理命令
# 查看任务详情
schtasks /query /tn "桔子网签到" /fo LIST /v
# 手动运行一次
schtasks /run /tn "桔子网签到"
# 修改时间(如改为 08:00)
schtasks /change /tn "桔子网签到" /st 08:00
# 删除任务
schtasks /delete /tn "桔子网签到" /f
📊 订阅流量查询脚本
功能说明
这是一个 Node.js 脚本,用于查询桔子云订阅的流量使用情况和到期时间。
| 功能 | 说明 |
|---|
| 获取流量信息 | 从响应头 subscription-userinfo 提取上传、下载、总量等数据 |
| 流量统计 | 将字节转换为 GB,计算已用、剩余、使用占比 |
| 到期计算 | 计算套餐剩余天数,以及每天需使用的流量配额 |
| 状态检测 | 检测套餐是否已过期 |
代码
const axios = require("axios")
const SUB_URL = "xxxxxxxx"
const USER_AGENT = "clash-verge/v1.3.7"
async function fetchSubscription() {
try {
const response = await axios({
method: "get",
url: SUB_URL,
headers: {
"User-Agent": USER_AGENT,
Accept: "application/yaml, application/octet-stream",
},
maxRedirects: 5,
})
console.log("最终响应状态码:", response.status)
const userInfo = response.headers["subscription-userinfo"]
if (userInfo) {
console.log("✅ 获取到流量信息 (原始):", userInfo)
const parts = userInfo.split(";").reduce((acc, item) => {
const [key, val] = item.trim().split("=")
if (key && val) acc[key.trim()] = parseInt(val, 10)
return acc
}, {})
console.log("\n📊 解析结果:")
console.log("上传 (bytes):", parts.upload)
console.log("下载 (bytes):", parts.download)
console.log("总量 (bytes):", parts.total)
console.log("过期时间戳:", parts.expire)
const uploadGB = parts.upload / 1024 ** 3
const downloadGB = parts.download / 1024 ** 3
const totalGB = parts.total / 1024 ** 3
const usedGB = (parts.upload + parts.download) / 1024 ** 3
const remainGB = (parts.total - parts.upload - parts.download) / 1024 ** 3
console.log("\n📦 流量统计 (GB):")
console.log("上传: ", uploadGB.toFixed(2), "GB")
console.log("下载: ", downloadGB.toFixed(2), "GB")
console.log("已用总计:", usedGB.toFixed(2), "GB")
console.log("套餐总量:", totalGB.toFixed(2), "GB")
console.log("剩余: ", remainGB.toFixed(2), "GB")
console.log("使用占比:", ((usedGB / totalGB) * 100).toFixed(2), "%")
const now = Math.floor(Date.now() / 1000)
const remainSeconds = parts.expire - now
const remainDays = Math.max(0, Math.ceil(remainSeconds / (24 * 60 * 60)))
console.log("\n📅 到期计算:")
console.log("过期时间:", new Date(parts.expire * 1000).toLocaleString("zh-CN"))
console.log("剩余天数:", remainDays, "天")
if (remainDays > 0) {
const dailyUsageGB = remainGB / remainDays
console.log("\n📊 每日流量分配:")
console.log("每天需用:", dailyUsageGB.toFixed(2), "GB 才能刚好用完")
} else {
console.log("\n⚠️ 套餐已过期或今天到期")
}
} else {
console.warn("⚠️ 响应头中没有 subscription-userinfo,可能该机场不支持此标准。")
}
} catch (error) {
console.error("❌ 请求失败:", error.message)
}
}
fetchSubscription()
使用方法
npm install axios
node fetch-subscription.js
输出示例
最终响应状态码: 200
✅ 获取到流量信息 (原始): upload=1234567890;download=9876543210;total=107374182400;expire=1735689600
📊 解析结果:
上传 (bytes): 1234567890
下载 (bytes): 9876543210
总量 (bytes): 107374182400
过期时间戳: 1735689600
📦 流量统计 (GB):
上传: 1.15 GB
下载: 9.20 GB
已用总计: 10.35 GB
套餐总量: 100.00 GB
剩余: 89.65 GB
使用占比: 10.35 %
📅 到期计算:
过期时间: 2025/12/31 08:00:00
剩余天数: 180 天
📊 每日流量分配:
每天需用: 0.50 GB 才能刚好用完
🚀 使用流程
- 安装油猴脚本:Tampermonkey → 新建脚本 → 粘贴代码 → 保存。
- 创建定时任务:以管理员身份运行 CMD,执行上述
schtasks /create 命令。 - 验证:手动打开
https://juzi52.net/user,观察控制台日志是否正常签到。
❓ 常见问题
| 问题 | 解决方案 |
|---|
| 按钮没点击 | 检查浏览器是否已登录 juzi52.net |
| 找不到签到按钮 | 页面结构变化,按 F12 检查新元素后更新选择器 |
| 定时任务报错 | 确保 CMD 以管理员身份运行 |
| 路径错误 | 检查 Edge 安装路径是否为 C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe |
📝 总结
| 环节 | 关键点 |
|---|
| 脚本 | @match 匹配目标 URL,#checkin-div a 定位按钮,checkin() 触发签到 |
| 定时任务 | 每天 7:51 自动打开浏览器 → 油猴脚本自动执行签到 |
| 流量查询 | 使用 Node.js 脚本查询订阅流量使用情况和到期时间 |
| 维护 | 网站改版时只需更新脚本中的选择器即可 |
配置完成后完全自动化,无需人工干预。🎉