♻️ refactor(substore): 优化重命名脚本中的线路标签与冗余尾号清洗逻辑

This commit is contained in:
Orion
2026-06-03 13:32:40 +08:00
parent ce9fac0504
commit 6c1e055281
3 changed files with 15 additions and 10 deletions
+6 -6
View File
@@ -25,7 +25,7 @@ https://git.orionc.me/orion/script/raw/branch/main/substore/common.js
| 脚本 | 建议配置位置 | 作用 | | 脚本 | 建议配置位置 | 作用 |
| --- | --- | --- | | --- | --- | --- |
| `sntp-rename.js` | SNTP 单订阅 | 注入 `[三网]``[CF]``[直连]``[cn2]` 等线路标签 | | `sntp-rename.js` | SNTP 单订阅 | 注入 `[三网]``[CFW]``[直连]``[cn2]` 等线路标签 |
| `yuetong-rename.js` | YueTong 单订阅 | 去掉 `悦·``💎`,把 `AI解锁` 压成 `AI` | | `yuetong-rename.js` | YueTong 单订阅 | 去掉 `悦·``💎`,把 `AI解锁` 压成 `AI` |
| `peiqian-rename.js` | PeiQian 单订阅 | 压短 `电信联通推荐``移动联通推荐``高速专线``hy2`、倍率和用途描述 | | `peiqian-rename.js` | PeiQian 单订阅 | 压短 `电信联通推荐``移动联通推荐``高速专线``hy2`、倍率和用途描述 |
| `alphaair-rename.js` | Alpha Air 单订阅 | 去掉提供者/三网/家宽文案,普通节点保留地区,高级非倍率节点保留供应商,倍率节点保留倍率并连续编号 | | `alphaair-rename.js` | Alpha Air 单订阅 | 去掉提供者/三网/家宽文案,普通节点保留地区,高级非倍率节点保留供应商,倍率节点保留倍率并连续编号 |
@@ -41,7 +41,7 @@ https://git.orionc.me/orion/script/raw/branch/main/substore/common.js
| --- | --- | | --- | --- |
| `GTM 0.5x` | `[三网]` | | `GTM 0.5x` | `[三网]` |
| `GTM` | `[三网]` | | `GTM` | `[三网]` |
| `CT` | `[CF]` | | `CT` | `[CFW]` |
| `D` | `[直连]` | | `D` | `[直连]` |
| `S1` | `[广移]` | | `S1` | `[广移]` |
| `S2` | `[广电]` | | `S2` | `[广电]` |
@@ -54,7 +54,7 @@ https://git.orionc.me/orion/script/raw/branch/main/substore/common.js
```text ```text
🇭🇰 HK-CT-1 0.2x - SNTP 🇭🇰 HK-CT-1 0.2x - SNTP
=> 🇭🇰 HK-CT-1 0.2x [CF] - SNTP => 🇭🇰 HK-CT-1 0.2x [CFW] - SNTP
🇯🇵 JP-D-1-0.2x - SNTP 🇯🇵 JP-D-1-0.2x - SNTP
=> 🇯🇵 JP-D-1-0.2x [直连] - SNTP => 🇯🇵 JP-D-1-0.2x [直连] - SNTP
@@ -145,7 +145,7 @@ https://git.orionc.me/orion/script/raw/branch/main/substore/common.js
- 支持国旗在中间的节点名,例如 `Pro-🇭🇰 Sharon|守夜人` -> `🇭🇰 HK Pro-Sharon|守夜人` - 支持国旗在中间的节点名,例如 `Pro-🇭🇰 Sharon|守夜人` -> `🇭🇰 HK Pro-Sharon|守夜人`
- 将倍率移动到节点核心末尾、订阅后缀之前,例如 `US 2X 02 - Alpha Air` -> `US 02 2X - Alpha Air` - 将倍率移动到节点核心末尾、订阅后缀之前,例如 `US 2X 02 - Alpha Air` -> `US 02 2X - Alpha Air`
- 清理 `[DIP China-Hongkong]``[DIP]` - 清理 `[DIP China-Hongkong]``[DIP]`
- 清理 `IEPL 专线` 这类冗余描述 - 清理 Alpha Flower 这类 `IEPL 专线 3``标准 1``高级 1` 的冗余线路尾号
- 追加订阅后缀 `- _subName` - 追加订阅后缀 `- _subName`
- 对最终重名节点追加两位编号。 - 对最终重名节点追加两位编号。
@@ -155,8 +155,8 @@ https://git.orionc.me/orion/script/raw/branch/main/substore/common.js
🇭🇰 Hong Kong 01 [DIP China-Hongkong] - Nexitally 🇭🇰 Hong Kong 01 [DIP China-Hongkong] - Nexitally
=> 🇭🇰 HK 01 [DIP] - Nexitally => 🇭🇰 HK 01 [DIP] - Nexitally
🇭🇰 香港实验性 IEPL 专线 1 - Alpha Flower 🇯🇵 日本高级 IEPL 专线 3 - Alpha Flower
=> 🇭🇰 HK 实验性 1 - Alpha Flower => 🇯🇵 JP 01 高级 - Alpha Flower
Pro-🇭🇰 Sharon|守夜人 - Alpha 8K Snell Pro-🇭🇰 Sharon|守夜人 - Alpha 8K Snell
=> 🇭🇰 HK Pro-Sharon|守夜人 - Alpha 8K Snell => 🇭🇰 HK Pro-Sharon|守夜人 - Alpha 8K Snell
+3 -2
View File
@@ -754,7 +754,7 @@ async function operator(proxies) {
} }
core = core core = core
.replace(/^([A-Z]{2})\s*(实验性|标准|高级)\s+IEPL\s+专线\s*(\d+)(.*)$/i, '$1 $2 $3$4') .replace(/^([A-Z]{2})\s*(实验性|标准|高级)\s+IEPL\s+专线\s*\d+(.*)$/i, '$1 $2$3')
.replace(/搬瓦工荷兰/g, '搬瓦工') .replace(/搬瓦工荷兰/g, '搬瓦工')
.replace(/\s{2,}/g, ' ') .replace(/\s{2,}/g, ' ')
.trim(); .trim();
@@ -770,7 +770,8 @@ async function operator(proxies) {
core = joinAlias(flagRegionCode, core); core = joinAlias(flagRegionCode, core);
} }
core = normalizeRegionSequence(moveMultiplierToEnd(simplifyCoreName(core))); core = normalizeRegionSequence(moveMultiplierToEnd(simplifyCoreName(core)))
.replace(/^([A-Z]{2}(?:\s+[A-Z]{3})?\s+\d{2}\s+(?:标准|高级))\s+1(?=$|\s)/i, '$1');
return flag ? `${flag} ${core}` : core; return flag ? `${flag} ${core}` : core;
}; };
+6 -2
View File
@@ -33,7 +33,7 @@ async function operator(proxies) {
const featureMap = { const featureMap = {
"GTM 0.5x": "三网", "GTM 0.5x": "三网",
"GTM": "三网", "GTM": "三网",
"CT": "CF", "CT": "CFW",
"S1": "广移", "S1": "广移",
"S2": "广电", "S2": "广电",
"S3": "广移", "S3": "广移",
@@ -112,11 +112,15 @@ async function operator(proxies) {
// 缓存后缀匹配正则,避免循环内重复创建 // 缓存后缀匹配正则,避免循环内重复创建
const suffixRegex = /\s*-\s*(SNTP.*)$/i; const suffixRegex = /\s*-\s*(SNTP.*)$/i;
const normalizeSntpSuffixSpacing = proxyName => proxyName.replace(suffixRegex, '-$1'); const normalizeSntpSuffixSpacing = proxyName => proxyName.replace(suffixRegex, '-$1');
const normalizeCloudflareLabel = proxyName => proxyName
.replace(/\s*\[(?:CF|Cloudflare)]\s*/gi, ' [CFW] ')
.replace(/\s{2,}/g, ' ')
.trim();
// 3. 执行节点遍历与注入 // 3. 执行节点遍历与注入
return proxies.map(proxy => { return proxies.map(proxy => {
if (typeof proxy.name !== 'string') return proxy; if (typeof proxy.name !== 'string') return proxy;
let proxyName = normalizeSntpSuffixSpacing(proxy.name); let proxyName = normalizeCloudflareLabel(normalizeSntpSuffixSpacing(proxy.name));
// 单次复合正则扫描提取 // 单次复合正则扫描提取
const featureMatch = proxyName.match(featureRegex); const featureMatch = proxyName.match(featureRegex);