-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
45 lines (35 loc) · 1.25 KB
/
Copy pathserver.js
File metadata and controls
45 lines (35 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/**
* 更新日期:2026-04-16
* 功能:批量修改 server/port,并将节点名完全替换为手动填写的 prefix
* 示例参数:
* #server=example.com&port=11451&prefix=example&filter=example
*/
const inArg = $arguments;
const NEW_SERVER = inArg.server || 'example.com';
const NEW_PORT = Number(inArg.port || 443);
const NEW_PREFIX = inArg.prefix || ''; // 手动填写的名字
const FILTER_KEY = inArg.filter || '';
const DEBUG = inArg.debug === 'true';
function operator(proxies) {
let modifiedCount = 0;
return proxies.map((proxy) => {
const originalName = proxy.name || "";
// 检查是否符合过滤条件
const shouldModify = !FILTER_KEY || originalName.includes(FILTER_KEY);
if (shouldModify) {
proxy.server = NEW_SERVER;
proxy.port = NEW_PORT;
// --- 简单的重命名逻辑 ---
// 如果提供了 prefix,就直接使用 prefix
// 如果 prefix 中包含 [index],则自动加上序号
let newName = NEW_PREFIX || originalName;
if (NEW_PREFIX.includes("[index]")) {
newName = NEW_PREFIX.replace("[index]", modifiedCount + 1);
}
proxy.name = newName;
proxy._subDisplayName = newName;
modifiedCount++;
}
return proxy;
});
}