Skip to content

Instantly share code, notes, and snippets.

@viko16
Created September 18, 2025 14:01
Show Gist options
  • Select an option

  • Save viko16/0a2b6c37e80218c3757a263c9d4e4e09 to your computer and use it in GitHub Desktop.

Select an option

Save viko16/0a2b6c37e80218c3757a263c9d4e4e09 to your computer and use it in GitHub Desktop.
根据节点名字添加一个 JP 分组
// https://mihomo.party/docs/guide/override/javascript
function main(config) {
// 创建一个新的代理组
const jpProxies = [];
const regx = /(日本|川日|东京|大阪|泉日|埼玉|沪日|深日|JP|Japan)/i;
// 遍历所有代理,检查名称是否以 "Japan-" 开头
config.proxies.forEach(proxy => {
if (proxy.name && regx.test(proxy.name)) {
jpProxies.push(proxy.name); // 将符合条件的代理加入 JP 组
}
});
// 如果找到符合条件的代理,动态生成并添加到 proxy-groups 里
if (jpProxies.length > 0) {
const jpGroup = {
name: "JP",
type: "url-test", // 可根据需要修改为其他类型
proxies: jpProxies,
url: "http://www.gstatic.com/generate_204",
interval: 300,
tolerance: 50
};
config["proxy-groups"].unshift(jpGroup); // 将新组添加到配置中
}
// 返回修改后的配置
return config;
}
# https://mihomo.party/docs/guide/override/yaml
+rules:
- GEOSITE,google-gemini,JP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment