♻️ refactor(substore): 重构重命名脚本并更新公共脚本链接版本
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
* - 不追加订阅后缀,整合订阅最后仍交给 rename.js 处理
|
* - 不追加订阅后缀,整合订阅最后仍交给 rename.js 处理
|
||||||
*/
|
*/
|
||||||
// noinspection JSUnusedGlobalSymbols
|
// noinspection JSUnusedGlobalSymbols
|
||||||
const COMMON_SCRIPT_URL = 'https://git.orionc.me/orion/script/raw/branch/main/substore/common.js';
|
const COMMON_SCRIPT_URL = 'https://git.orionc.me/orion/script/raw/branch/main/substore/common.js?v=20260603-2';
|
||||||
|
|
||||||
async function loadRenameUtils() {
|
async function loadRenameUtils() {
|
||||||
if (typeof globalThis !== 'undefined' && globalThis.SubStoreRenameUtils) {
|
if (typeof globalThis !== 'undefined' && globalThis.SubStoreRenameUtils) {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
* 负责去掉高速、BGP、CMCU 等 LiangXin 线路描述,保留地区、序号和倍率。
|
* 负责去掉高速、BGP、CMCU 等 LiangXin 线路描述,保留地区、序号和倍率。
|
||||||
*/
|
*/
|
||||||
// noinspection JSUnusedGlobalSymbols
|
// noinspection JSUnusedGlobalSymbols
|
||||||
const COMMON_SCRIPT_URL = 'https://git.orionc.me/orion/script/raw/branch/main/substore/common.js';
|
const COMMON_SCRIPT_URL = 'https://git.orionc.me/orion/script/raw/branch/main/substore/common.js?v=20260603-2';
|
||||||
|
|
||||||
async function loadRenameUtils() {
|
async function loadRenameUtils() {
|
||||||
if (typeof globalThis !== 'undefined' && globalThis.SubStoreRenameUtils) {
|
if (typeof globalThis !== 'undefined' && globalThis.SubStoreRenameUtils) {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
* 负责清理推荐、用途、hy2、倍率、线路特征和提供商等 PeiQian 节点文案。
|
* 负责清理推荐、用途、hy2、倍率、线路特征和提供商等 PeiQian 节点文案。
|
||||||
*/
|
*/
|
||||||
// noinspection JSUnusedGlobalSymbols
|
// noinspection JSUnusedGlobalSymbols
|
||||||
const COMMON_SCRIPT_URL = 'https://git.orionc.me/orion/script/raw/branch/main/substore/common.js';
|
const COMMON_SCRIPT_URL = 'https://git.orionc.me/orion/script/raw/branch/main/substore/common.js?v=20260603-2';
|
||||||
|
|
||||||
async function loadRenameUtils() {
|
async function loadRenameUtils() {
|
||||||
if (typeof globalThis !== 'undefined' && globalThis.SubStoreRenameUtils) {
|
if (typeof globalThis !== 'undefined' && globalThis.SubStoreRenameUtils) {
|
||||||
|
|||||||
+39
-2
@@ -5,7 +5,7 @@
|
|||||||
* - 基于归一化后的完整名称做精准去重
|
* - 基于归一化后的完整名称做精准去重
|
||||||
*/
|
*/
|
||||||
// noinspection JSUnusedGlobalSymbols
|
// noinspection JSUnusedGlobalSymbols
|
||||||
const COMMON_SCRIPT_URL = 'https://git.orionc.me/orion/script/raw/branch/main/substore/common.js';
|
const COMMON_SCRIPT_URL = 'https://git.orionc.me/orion/script/raw/branch/main/substore/common.js?v=20260603-2';
|
||||||
|
|
||||||
async function loadRenameUtils() {
|
async function loadRenameUtils() {
|
||||||
if (typeof globalThis !== 'undefined' && globalThis.SubStoreRenameUtils) {
|
if (typeof globalThis !== 'undefined' && globalThis.SubStoreRenameUtils) {
|
||||||
@@ -26,6 +26,43 @@ async function loadRenameUtils() {
|
|||||||
|
|
||||||
async function operator(proxies) {
|
async function operator(proxies) {
|
||||||
const utils = await loadRenameUtils();
|
const utils = await loadRenameUtils();
|
||||||
|
const normalizeHyphenatedRegionFeatures = utils.normalizeHyphenatedRegionFeatures || (name => {
|
||||||
|
const hyphenatedMatch = String(name).match(/^([A-Z]{2})(?:\s+([A-Z]{3}))?-(.+)$/);
|
||||||
|
if (!hyphenatedMatch) return name;
|
||||||
|
|
||||||
|
const countryCode = hyphenatedMatch[1];
|
||||||
|
let regionCode = hyphenatedMatch[2]
|
||||||
|
? `${countryCode} ${hyphenatedMatch[2]}`
|
||||||
|
: countryCode;
|
||||||
|
const tokens = hyphenatedMatch[3].split('-').map(token => token.trim()).filter(Boolean);
|
||||||
|
|
||||||
|
if (
|
||||||
|
!hyphenatedMatch[2] &&
|
||||||
|
tokens.length >= 2 &&
|
||||||
|
/^[A-Z]{3}$/.test(tokens[0]) &&
|
||||||
|
/^\d{1,2}$/.test(tokens[1])
|
||||||
|
) {
|
||||||
|
regionCode = `${countryCode} ${tokens.shift()}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const sequenceIndex = tokens.findIndex(token => /^\d{1,2}$/.test(token));
|
||||||
|
if (sequenceIndex === -1) return name;
|
||||||
|
|
||||||
|
const sequenceNumber = tokens[sequenceIndex].padStart(2, '0');
|
||||||
|
const ingressTokens = tokens
|
||||||
|
.slice(0, sequenceIndex)
|
||||||
|
.map(token => token.toUpperCase());
|
||||||
|
const egressTokens = tokens.slice(sequenceIndex + 1);
|
||||||
|
const featureText = ingressTokens.length && egressTokens.length
|
||||||
|
? `${ingressTokens.join('-')}-${egressTokens.join('-')}`
|
||||||
|
: [...ingressTokens, ...egressTokens].join('-');
|
||||||
|
|
||||||
|
return [regionCode, sequenceNumber, featureText]
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(' ')
|
||||||
|
.replace(/\s{2,}/g, ' ')
|
||||||
|
.trim();
|
||||||
|
});
|
||||||
const globalCount = Object.create(null);
|
const globalCount = Object.create(null);
|
||||||
const currentCount = Object.create(null);
|
const currentCount = Object.create(null);
|
||||||
const baseNames = new Array(proxies.length);
|
const baseNames = new Array(proxies.length);
|
||||||
@@ -770,7 +807,7 @@ async function operator(proxies) {
|
|||||||
core = joinAlias(flagRegionCode, core);
|
core = joinAlias(flagRegionCode, core);
|
||||||
}
|
}
|
||||||
|
|
||||||
core = normalizeRegionSequence(utils.normalizeHyphenatedRegionFeatures(moveMultiplierToEnd(simplifyCoreName(core))))
|
core = normalizeRegionSequence(normalizeHyphenatedRegionFeatures(moveMultiplierToEnd(simplifyCoreName(core))))
|
||||||
.replace(/^([A-Z]{2}(?:\s+[A-Z]{3})?\s+\d{2}\s+(?:标准|高级))\s+1(?=$|\s)/i, '$1');
|
.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;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
* 维护说明:仅需修改 featureMap 字典即可,底部逻辑永远无需改动。
|
* 维护说明:仅需修改 featureMap 字典即可,底部逻辑永远无需改动。
|
||||||
*/
|
*/
|
||||||
// noinspection JSUnusedGlobalSymbols
|
// noinspection JSUnusedGlobalSymbols
|
||||||
const COMMON_SCRIPT_URL = 'https://git.orionc.me/orion/script/raw/branch/main/substore/common.js';
|
const COMMON_SCRIPT_URL = 'https://git.orionc.me/orion/script/raw/branch/main/substore/common.js?v=20260603-2';
|
||||||
|
|
||||||
async function loadRenameUtils() {
|
async function loadRenameUtils() {
|
||||||
if (typeof globalThis !== 'undefined' && globalThis.SubStoreRenameUtils) {
|
if (typeof globalThis !== 'undefined' && globalThis.SubStoreRenameUtils) {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
* 按地区稳定归并后重新连续编号,避免专属/普通节点撞号。
|
* 按地区稳定归并后重新连续编号,避免专属/普通节点撞号。
|
||||||
*/
|
*/
|
||||||
// noinspection JSUnusedGlobalSymbols
|
// noinspection JSUnusedGlobalSymbols
|
||||||
const COMMON_SCRIPT_URL = 'https://git.orionc.me/orion/script/raw/branch/main/substore/common.js';
|
const COMMON_SCRIPT_URL = 'https://git.orionc.me/orion/script/raw/branch/main/substore/common.js?v=20260603-2';
|
||||||
|
|
||||||
async function loadRenameUtils() {
|
async function loadRenameUtils() {
|
||||||
if (typeof globalThis !== 'undefined' && globalThis.SubStoreRenameUtils) {
|
if (typeof globalThis !== 'undefined' && globalThis.SubStoreRenameUtils) {
|
||||||
|
|||||||
Reference in New Issue
Block a user