feat(substore): 新增 peiqian 和 yuetong 重命名脚本并优化现有脚本注释

This commit is contained in:
Orion
2026-06-03 10:12:11 +08:00
parent 93bb6a7a6c
commit 07ef71bf4a
5 changed files with 78 additions and 9 deletions
+8 -3
View File
@@ -5,6 +5,7 @@
* - 按地区内“普通 -> 倍率 -> 高级”排序并连续编号
* - 不追加订阅后缀,整合订阅最后仍交给 rename.js 处理
*/
// noinspection JSUnusedGlobalSymbols
function operator(proxies) {
const regionAliases = [
['美国夏威夷', 'US HNL'],
@@ -97,7 +98,7 @@ function operator(proxies) {
const providerOf = name => {
if (/SkyStroll/i.test(name)) return 'SkyStroll';
if (/isif/i.test(name)) return 'ISIF';
if (/(?:搬瓦工|Bandwagon|BWH|BWG)/i.test(name)) return 'BWH';
if (/搬瓦工|Bandwagon|BWH|BWG/i.test(name)) return 'BWH';
return '';
};
@@ -109,7 +110,7 @@ function operator(proxies) {
const aliasRegionPrefixOf = name => {
const cleanNameLower = name.toLowerCase();
for (const [alias, replacement, aliasLower] of sortedRegionAliases) {
for (const [, replacement, aliasLower] of sortedRegionAliases) {
if (cleanNameLower.includes(aliasLower)) return replacement;
}
@@ -123,7 +124,7 @@ function operator(proxies) {
};
const regionPrefixOf = (name, flagRegionCode) => {
if (/(?:Hinet|Seednet)/i.test(name)) return 'TW';
if (/Hinet|Seednet/i.test(name)) return 'TW';
return aliasRegionPrefixOf(name) ||
leadingRegionPrefixOf(name) ||
@@ -168,6 +169,10 @@ function operator(proxies) {
});
normalizedItems.sort((firstItem, secondItem) => {
if (!firstItem.countryCode || !secondItem.countryCode) {
return firstItem.originalIndex - secondItem.originalIndex;
}
const firstOrder = countryOrder[firstItem.countryCode];
const secondOrder = countryOrder[secondItem.countryCode];
if (firstOrder !== secondOrder) return firstOrder - secondOrder;
+34
View File
@@ -0,0 +1,34 @@
/**
* PeiQian 专用节点清理脚本
* 负责清理推荐、用途、hy2、倍率等 PeiQian 节点文案。
*/
// noinspection JSUnusedGlobalSymbols
function operator(proxies) {
return proxies.map(proxy => {
if (typeof proxy.name !== 'string') {
return proxy;
}
proxy.name = proxy.name
.replace(/^AWS\s*新加坡\s*/i, '新加坡 AWS ')
.replace(/\s*\|\s*合适下载使用\s*-\s*(\d+(?:\.\d+)?)倍/gi, ' $1x')
.replace(/\s*\|\s*合适下载使用/gi, '')
.replace(/\s*\|\s*避免晚高峰使用/gi, '')
.replace(/\s*\|\s*电信联通移动推荐\s*-\s*hy2/gi, ' [三网 HY2]')
.replace(/\s*\|\s*电信联通移动推荐/gi, ' [三网]')
.replace(/\s*\|\s*电信联通推荐\s*-\s*hy2/gi, ' [电联 HY2]')
.replace(/\s*\|\s*电信联通推荐/gi, ' [电联]')
.replace(/\s*\|\s*移动联通推荐\s*-\s*hy2/gi, ' [移联 HY2]')
.replace(/\s*\|\s*移动联通推荐/gi, ' [移联]')
.replace(/\s*\|\s*高速专线(?:推荐)?\s*-\s*hy2/gi, ' [HY2]')
.replace(/\s*\|\s*高速专线推荐/gi, ' [专线]')
.replace(/\s*\|\s*三网推荐/gi, ' [三网]')
.replace(/-\s*(\d+(?:\.\d+)?)倍/gi, ' $1x')
.replace(/(\d+(?:\.\d+)?)倍/gi, '$1x')
.replace(/\s+\[/g, ' [')
.replace(/\s{2,}/g, ' ')
.trim();
return proxy;
});
}
+10 -5
View File
@@ -4,6 +4,7 @@
* - 清理常见冗余线路描述,例如 DIP 地区说明、IEPL 专线
* - 基于归一化后的完整名称做精准去重
*/
// noinspection JSUnusedGlobalSymbols
function operator(proxies) {
const globalCount = Object.create(null);
const currentCount = Object.create(null);
@@ -552,7 +553,10 @@ function operator(proxies) {
);
Object.values(flagCodeOverrides).forEach(code => knownRegionCodes.add(code));
const escapeRegex = value => value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
const regexSpecialChars = new Set(['.', '*', '+', '?', '^', '$', '{', '}', '(', ')', '|', '[', ']', '\\']);
const escapeRegex = value => [...value]
.map(char => regexSpecialChars.has(char) ? `\\${char}` : char)
.join('');
const leadingFlagRegex = /^([\u{1F1E6}-\u{1F1FF}]{2}|🏴‍☠️)\s*/u;
const inlineFlagRegex = /^(.{1,24}?)([\u{1F1E6}-\u{1F1FF}]{2}|🏴‍☠️)\s*(.*)$/u;
@@ -692,15 +696,16 @@ function operator(proxies) {
}
core = core
.replace(/\[DIP[^\]]*\]/gi, '[DIP]');
.replace(/\[DIP.*?]/gi, '[DIP]');
core = normalizeBilingualName(core);
core = normalizeLeadingRegion(core);
if (/^Pro-\s*/i.test(core)) {
core = core.replace(/^(Pro-\s*)(.+)$/i, (fullMatch, proPrefix, restName) => {
return `${proPrefix}${normalizeLeadingRegion(restName)}`;
});
const proMatch = core.match(/^(Pro-\s*)(.+)$/i);
if (proMatch) {
core = `${proMatch[1]}${normalizeLeadingRegion(proMatch[2])}`;
}
}
core = core
+5 -1
View File
@@ -3,6 +3,7 @@
* 核心架构:动态按长度排序编译正则 + 智能边界识别 + O(1) 映射提取
* 维护说明:仅需修改 featureMap 字典即可,底部逻辑永远无需改动。
*/
// noinspection JSUnusedGlobalSymbols
function operator(proxies) {
// ================= 唯一配置区 =================
// 在这里新增或修改关键词。格式:"节点关键词": "想要注入的标签"
@@ -29,7 +30,10 @@ function operator(proxies) {
const normalizedFeatureMap = {};
const featureKeywords = Object.keys(featureMap);
const normalizeFeatureKeyword = keyword => keyword.toUpperCase().replace(/\s+/g, '');
const escapeRegexKeyword = keyword => keyword.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
const regexSpecialChars = new Set(['.', '*', '+', '?', '^', '$', '{', '}', '(', ')', '|', '[', ']', '\\']);
const escapeRegexKeyword = keyword => [...keyword]
.map(char => regexSpecialChars.has(char) ? `\\${char}` : char)
.join('');
for (const featureKeyword of featureKeywords) {
normalizedFeatureMap[normalizeFeatureKeyword(featureKeyword)] = featureMap[featureKeyword];
}
+21
View File
@@ -0,0 +1,21 @@
/**
* YueTong 专用节点清理脚本
* 负责去掉“悦·”品牌前缀、钻石等装饰,以及压短 AI 解锁文案。
*/
// noinspection JSUnusedGlobalSymbols
function operator(proxies) {
return proxies.map(proxy => {
if (typeof proxy.name !== 'string') {
return proxy;
}
proxy.name = proxy.name
.replace(/悦[·・]\s*/g, '')
.replace(/AI解锁/g, 'AI')
.replace(/💎/gu, '')
.replace(/\s{2,}/g, ' ')
.trim();
return proxy;
});
}