更新 Scripts/nodeseek.js
This commit is contained in:
@@ -380,29 +380,36 @@ function ObjectKeys2LowerCase(obj) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ====================== 入口 ====================== */
|
/* ====================== 入口 ====================== */
|
||||||
const SCRIPT_VERSION = "v3-debug-2026-04-30";
|
const SCRIPT_VERSION = "v5-url-based";
|
||||||
|
|
||||||
!(async () => {
|
!(async () => {
|
||||||
try {
|
try {
|
||||||
// 版本标记 + 环境诊断(解决 "cron 误入抓 cookie 分支" 问题用)
|
$.log(`\n========== 🚀 ${SCRIPT_VERSION} 已加载 ==========\n`);
|
||||||
$.log(`[VERSION] ${SCRIPT_VERSION}`);
|
|
||||||
$.log(`[ENV] $request=${typeof $request}, $response=${typeof $response}, $argument=${typeof $argument}`);
|
|
||||||
if (typeof $request !== "undefined" && $request) {
|
|
||||||
$.log(`[ENV] $request keys: ${Object.keys($request || {}).join(",")}`);
|
|
||||||
$.log(`[ENV] $request.url: ${$request.url || "<none>"}`);
|
|
||||||
}
|
|
||||||
if (typeof $response !== "undefined" && $response) {
|
|
||||||
$.log(`[ENV] $response keys: ${Object.keys($response || {}).join(",")}`);
|
|
||||||
$.log(`[ENV] $response.body length: ${$response.body ? $response.body.length : "<none>"}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 判断运行模式:
|
// 模式判断:基于 $request.url 是否真的指向 nodeseek 的 getInfo API
|
||||||
// - http-response 脚本:$response 存在(含 body)→ 抓 cookie
|
//
|
||||||
// - cron / 手动执行 / Node.js:$response 不存在 → 签到
|
// 背景:Surge 在手动运行 cron 脚本时,会注入一个 mock 的 $request/$response
|
||||||
// 不能用 $request 判断,因为某些 Surge 版本在 cron 里也会注入 $request
|
// 上下文($request.url 通常是 http://www.apple.com/,
|
||||||
const isMitmMode =
|
// $response.body 是 {"foo":"bar"})。所以单纯用 typeof 判断
|
||||||
typeof $response !== "undefined" && $response && $response.body;
|
// 全局变量是否存在不可靠。
|
||||||
$.log(`[ENV] isMitmMode=${isMitmMode}`);
|
//
|
||||||
|
// 真实分支:
|
||||||
|
// - MITM 触发:$request.url = https://www.nodeseek.com/api/account/getInfo/<id>?...
|
||||||
|
// - cron / 手动执行:$request.url 是 mock 值,不含 nodeseek 域名
|
||||||
|
// - Node.js:$request 不存在
|
||||||
|
const reqUrl =
|
||||||
|
typeof $request !== "undefined" &&
|
||||||
|
$request &&
|
||||||
|
typeof $request.url === "string"
|
||||||
|
? $request.url
|
||||||
|
: "";
|
||||||
|
const isMitmMode = reqUrl.includes("nodeseek.com/api/account/getInfo");
|
||||||
|
|
||||||
|
$.log(
|
||||||
|
`[mode] $request.url="${reqUrl || "<none>"}" → ${
|
||||||
|
isMitmMode ? "抓cookie" : "签到"
|
||||||
|
}`
|
||||||
|
);
|
||||||
|
|
||||||
if (isMitmMode) {
|
if (isMitmMode) {
|
||||||
await getCookie();
|
await getCookie();
|
||||||
|
|||||||
Reference in New Issue
Block a user