50 lines
2.0 KiB
JavaScript
50 lines
2.0 KiB
JavaScript
/**
|
|
* PeiQian 专用节点清理脚本
|
|
* 负责清理推荐、用途、hy2、倍率、线路特征和提供商等 PeiQian 节点文案。
|
|
*/
|
|
// noinspection JSUnusedGlobalSymbols
|
|
const COMMON_SCRIPT_URL = 'https://git.orionc.me/orion/script/raw/branch/main/substore/common.js?v=20260603-4';
|
|
|
|
async function loadRenameUtils() {
|
|
if (typeof globalThis !== 'undefined' && 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))();
|
|
return globalThis.SubStoreRenameUtils;
|
|
}
|
|
|
|
async function operator(proxies) {
|
|
const utils = await loadRenameUtils();
|
|
|
|
return proxies.map(proxy => {
|
|
if (typeof proxy.name !== 'string') {
|
|
return proxy;
|
|
}
|
|
|
|
proxy.name = proxy.name
|
|
.replace(/AWS\s*(?=新加坡)/gi, '')
|
|
.replace(/\s*\|\s*合适下载使用\s*-\s*(\d+(?:\.\d+)?)倍/gi, ' $1x')
|
|
.replace(/\s*\|\s*合适下载使用/gi, '')
|
|
.replace(/\s*\|\s*避免晚高峰使用/gi, '')
|
|
.replace(/\s*\|\s*(?:电信联通移动|电信联通|移动联通|三网)推荐(?:\s*-\s*hy2)?/gi, '')
|
|
.replace(/\s*\|\s*高速专线(?:推荐)?(?:\s*-\s*hy2)?/gi, '')
|
|
.replace(/-\s*(\d+(?:\.\d+)?)倍/gi, ' $1x')
|
|
.replace(/(\d+(?:\.\d+)?)倍/gi, '$1x')
|
|
.replace(/\s*\[(?:专线|移联|电联|三网|HY2)(?:\s+(?:专线|移联|电联|三网|HY2))*\]/gi, '')
|
|
.replace(/\s+\[/g, ' [')
|
|
.replace(/\s{2,}/g, ' ');
|
|
proxy.name = utils.normalizeLeadingFlagSpacing(proxy.name);
|
|
|
|
return proxy;
|
|
});
|
|
}
|