Files
ql-scripts/jd/scrip_moving_env_enhance.js
zhuhjay 87debf37a9 chore(meta): 三个脚本统一青龙元数据注解,新增 _probe_meta.js 自检
继 3531437 修好 qqmusic 之后,把同一问题在另两个脚本上一并清掉 ——
它们原本都没写 name 注解(任务名会退回文件名),且 jd 脚本的 cron 写在块注释里
用了 */ 转义,青龙会把反斜杠一起提取出去。

改动(三个脚本统一成同一形态:文件最前面两行行注释):
  // cron: <表达式>
  // name: <中文任务名>

- jd/scrip_moving_env_enhance.js: 补 name 注解;cron 从块注释移到行注释
  (原来写的 \*/ 转义会产出非法表达式)
- xiequ/scrip_switch.js: 补 name 注解;正文两处日志里的「name: xxx」改成「账号 xxx」
  (青龙的任务名正则不锚定行首、取全文第一个命中,正文命中会盖掉注解)
- qqmusic/scrip_qqmusic_checkin.js: 注解从块注释改成行注释,与另两个统一
- 新增 _probe_meta.js: 扫描所有 scrip_*.js,复刻旧版(/name:\s*(.+)/ 不锚定)
  与新版(cli/src/internal/subscription 的 cronMetadata)两条提取逻辑,
  断言任务名不是代码片段、cron 是合法表达式。不带 scrip_ 前缀,订阅不会拉取

验证:_probe_meta.js RESULT: PASS(3 个文件,两个版本青龙提取都正确)/
三个脚本 node --check 全过 / qqmusic 签名对拍 6 组 PASS / 空 env 优雅跳过
2026-11-04 21:22:38 +08:00

78 lines
2.6 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// cron: 59 23 */3 * *
// name: 京东Cookie辅助脚本
/**
* 京东Cookie辅助脚本(将JD CK进行重排序 保证所有账号都有助力与被助力的机会)
*
* 上面两行是青龙订阅自动建任务用的元数据注解,格式约定见仓库根 README:
* - 必须用行注释写在文件最前面(行首),不要塞进块注释 —— 块注释里 cron 的
* 「星号斜杠」会被迫转义,青龙会把反斜杠一起提取出去。
* - 全文不要出现第二处「name 加冒号」的连写:青龙的提取正则不锚定行首,
* 取的是全文第一个命中。
*/
const { Env } = require('../common');
const $ = new Env('京东Cookie辅助脚本');
const fs = require('fs').promises;
const fetch = require('node-fetch');
const envName = 'JD_COOKIE';
const qlPanelUrl = 'https://ql.zhuhjay.cn';
!(async () => {
let token = JSON.parse(await fs.readFile('/ql/data/config/auth.json', 'utf-8'))?.token;
if(!token) return $.log('未登录');
const rsp1 = await fetch(`${qlPanelUrl}/api/envs?t=${Date.now()}`, {
"headers": {
"authorization": `Bearer ${token}`,
"content-type": 'application/json'
},
"body": null,
"method": "GET",
});
const { data } = await rsp1.json();
let cks = data.map((item, idx) => {
return {
idx,
item
}
}).filter(d => d.item.name === envName && d.item.status === 0);
// 将最后一个放置到最前
let moveingCk = cks[cks.length - 1];
let toIdx = 0;
const rsp2 = await fetch(`${qlPanelUrl}/api/envs/${moveingCk.item.id}/move?t=${Date.now()}`, {
"headers": {
"authorization": `Bearer ${token}`,
"content-type": 'application/json'
},
"body": JSON.stringify({
fromIndex: moveingCk.idx,
toIndex: toIdx
}),
"method": "PUT",
});
await rsp2.json();
// 将 第一个 ck 移动到最后一个即可
// let moveingCk = cks[0];
// let toIdx = cks[cks.length - 1].idx;
// const rsp2 = await fetch(`${qlPanelUrl}/api/envs/${moveingCk.item.id}/move?t=${Date.now()}`, {
// "headers": {
// "authorization": `Bearer ${token}`,
// "content-type": 'application/json'
// },
// "body": JSON.stringify({
// fromIndex: moveingCk.idx,
// toIndex: toIdx
// }),
// "method": "PUT",
// });
// await rsp2.json();
})()
.catch((e) => {
$.logErr(e);
})
.finally(() => {
$.done();
});