7a62f839f1
- 从各个重命名脚本中移除重复的工具函数实现 - 将 multiplierOf、multiplierValueOf、stripSubscriptionSuffix 等函数统一到 common.js - 使用 utils.multiplierOf、utils.multiplierValueOf 替代本地实现 - 引入 utils.createSequenceCounter 替代手动计数逻辑 - 更新版本号从 20260608-1 到 20260702-1 - 移除重复的正则表达式匹配逻辑 - 标准化序列计数器实现方式 - 优化 yinyun-rename.js 中的信息节点过滤逻辑
73 lines
2.0 KiB
JavaScript
73 lines
2.0 KiB
JavaScript
/**
|
|
* LiangXin 专用节点清理脚本
|
|
* 负责去掉高速、BGP、CMCU 等 LiangXin 线路描述,保留地区、序号和倍率。
|
|
*/
|
|
// noinspection JSUnusedGlobalSymbols
|
|
const COMMON_SCRIPT_VERSION = '20260702-1';
|
|
const COMMON_SCRIPT_URL = `https://git.orionc.me/orion/script/raw/branch/main/substore/common.js?v=${COMMON_SCRIPT_VERSION}`;
|
|
const hasCurrentRenameUtils = utils => Boolean(
|
|
utils && utils.version === COMMON_SCRIPT_VERSION
|
|
);
|
|
|
|
async function loadRenameUtils() {
|
|
if (typeof globalThis !== 'undefined' && hasCurrentRenameUtils(globalThis.SubStoreRenameUtils)) {
|
|
return globalThis.SubStoreRenameUtils;
|
|
}
|
|
|
|
const cache = typeof scriptResourceCache !== 'undefined' ? scriptResourceCache : null;
|
|
let script = cache && cache.get(COMMON_SCRIPT_URL);
|
|
if (!script) {
|
|
const response = await $substore.http.get({ url: COMMON_SCRIPT_URL });
|
|
script = response && (response.body || response.data || response);
|
|
if (cache) cache.set(COMMON_SCRIPT_URL, script);
|
|
}
|
|
|
|
new Function(String(script))();
|
|
if (!hasCurrentRenameUtils(globalThis.SubStoreRenameUtils)) {
|
|
throw new Error('Loaded common.js is missing current rename utilities');
|
|
}
|
|
return globalThis.SubStoreRenameUtils;
|
|
}
|
|
|
|
async function operator(proxies) {
|
|
const utils = await loadRenameUtils();
|
|
const lineDescriptorKeywords = [
|
|
'CMCU',
|
|
'CUCM',
|
|
'CMCT',
|
|
'CTCM',
|
|
'CUCT',
|
|
'CTCU',
|
|
'BGP',
|
|
'CMI',
|
|
'CUG',
|
|
'CN2',
|
|
'IEPL',
|
|
'IPLC',
|
|
'9929',
|
|
'4837',
|
|
'CM',
|
|
'CU',
|
|
'CT',
|
|
'高速',
|
|
'极速',
|
|
'专线',
|
|
'中转',
|
|
'直连',
|
|
'隧道',
|
|
'三网',
|
|
'移动',
|
|
'联通',
|
|
'电信'
|
|
];
|
|
|
|
return proxies.map(proxy => {
|
|
if (typeof proxy.name !== 'string') {
|
|
return proxy;
|
|
}
|
|
|
|
proxy.name = utils.stripLineDescriptors(proxy.name, lineDescriptorKeywords);
|
|
return proxy;
|
|
});
|
|
}
|