分享两个我自用的超强clash-verge全局扩展脚本,自定义分流,ChatGPT,Netflix解锁!
clash-verge全局脚本1:
// 国内DNS服务器
const domesticNameservers = [
"https://dns.alidns.com/dns-query", // 阿里云公共DNS
"https://doh.pub/dns-query", // 腾讯DNSPod
"https://doh.360.cn/dns-query" // 360安全DNS
];
// 国外DNS服务器
const foreignNameservers = [
"https://1.1.1.1/dns-query", // Cloudflare(主)
"https://1.0.0.1/dns-query", // Cloudflare(备)
"https://208.67.222.222/dns-query", // OpenDNS(主)
"https://208.67.220.220/dns-query", // OpenDNS(备)
"https://194.242.2.2/dns-query", // Mullvad(主)
"https://194.242.2.3/dns-query" // Mullvad(备)
];
// DNS配置
const dnsConfig = {
"enable": true,
"listen": "0.0.0.0:1053",
"ipv6": true,
"use-system-hosts": false,
"cache-algorithm": "arc",
"enhanced-mode": "fake-ip",
"fake-ip-range": "198.18.0.1/16",
"fake-ip-filter": [
// 本地主机/设备
"+.lan",
"+.local",
// Windows网络出现小地球图标
"+.msftconnecttest.com",
"+.msftncsi.com",
// QQ快速登录检测失败
"localhost.ptlogin2.qq.com",
"localhost.sec.qq.com",
// 微信快速登录检测失败
"localhost.work.weixin.qq.com"
],
"default-nameserver": ["223.5.5.5", "119.29.29.29", "1.1.1.1", "8.8.8.8"],
"nameserver": [...domesticNameservers, ...foreignNameservers],
"proxy-server-nameserver": [...domesticNameservers, ...foreignNameservers],
"nameserver-policy": {
"geosite:private,cn,geolocation-cn": domesticNameservers,
"geosite:google,youtube,telegram,gfw,geolocation-!cn": foreignNameservers
}
};
// 规则集通用配置
const ruleProviderCommon = {
"type": "http",
"format": "yaml",
"interval": 86400
};
// 规则集配置
const ruleProviders = {
"reject": {
...ruleProviderCommon,
"behavior": "domain",
"url": "https://fastly.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/reject.txt",
"path": "./ruleset/loyalsoldier/reject.yaml"
},
"icloud": {
...ruleProviderCommon,
"behavior": "domain",
"url": "https://fastly.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/icloud.txt",
"path": "./ruleset/loyalsoldier/icloud.yaml"
},
"apple": {
...ruleProviderCommon,
"behavior": "domain",
"url": "https://fastly.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/apple.txt",
"path": "./ruleset/loyalsoldier/apple.yaml"
},
"google": {
...ruleProviderCommon,
"behavior": "domain",
"url": "https://fastly.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/google.txt",
"path": "./ruleset/loyalsoldier/google.yaml"
},
"proxy": {
...ruleProviderCommon,
"behavior": "domain",
"url": "https://fastly.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/proxy.txt",
"path": "./ruleset/loyalsoldier/proxy.yaml"
},
"direct": {
...ruleProviderCommon,
"behavior": "domain",
"url": "https://fastly.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/direct.txt",
"path": "./ruleset/loyalsoldier/direct.yaml"
},
"private": {
...ruleProviderCommon,
"behavior": "domain",
"url": "https://fastly.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/private.txt",
"path": "./ruleset/loyalsoldier/private.yaml"
},
"gfw": {
...ruleProviderCommon,
"behavior": "domain",
"url": "https://fastly.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/gfw.txt",
"path": "./ruleset/loyalsoldier/gfw.yaml"
},
"tld-not-cn": {
...ruleProviderCommon,
"behavior": "domain",
"url": "https://fastly.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/tld-not-cn.txt",
"path": "./ruleset/loyalsoldier/tld-not-cn.yaml"
},
"telegramcidr": {
...ruleProviderCommon,
"behavior": "ipcidr",
"url": "https://fastly.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/telegramcidr.txt",
"path": "./ruleset/loyalsoldier/telegramcidr.yaml"
},
"cncidr": {
...ruleProviderCommon,
"behavior": "ipcidr",
"url": "https://fastly.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/cncidr.txt",
"path": "./ruleset/loyalsoldier/cncidr.yaml"
},
"lancidr": {
...ruleProviderCommon,
"behavior": "ipcidr",
"url": "https://fastly.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/lancidr.txt",
"path": "./ruleset/loyalsoldier/lancidr.yaml"
},
"applications": {
...ruleProviderCommon,
"behavior": "classical",
"url": "https://fastly.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/applications.txt",
"path": "./ruleset/loyalsoldier/applications.yaml"
},
"openai": {
...ruleProviderCommon,
"behavior": "classical",
"url": "https://fastly.jsdelivr.net/gh/blackmatrix7/ios_rule_script@master/rule/Clash/OpenAI/OpenAI.yaml",
"path": "./ruleset/blackmatrix7/openai.yaml"
}
};
// 规则
const rules = [
// 自定义规则
"DOMAIN-SUFFIX,googleapis.cn,节点选择", // Google服务
"DOMAIN-SUFFIX,gstatic.com,节点选择", // Google静态资源
"DOMAIN-SUFFIX,xn--ngstr-lra8j.com,节点选择", // Google Play下载服务
"DOMAIN-SUFFIX,github.io,节点选择", // Github Pages
"DOMAIN,v2rayse.com,节点选择", // V2rayse节点工具
// blackmatrix7 规则集
"RULE-SET,openai,ChatGPT",
// Loyalsoldier 规则集
//"RULE-SET,applications,全局直连",
"RULE-SET,private,全局直连",
"RULE-SET,reject,广告过滤",
"RULE-SET,icloud,微软服务",
"RULE-SET,apple,苹果服务",
"RULE-SET,google,谷歌服务",
"RULE-SET,proxy,节点选择",
"RULE-SET,gfw,节点选择",
"RULE-SET,tld-not-cn,节点选择",
"RULE-SET,direct,全局直连",
"RULE-SET,lancidr,全局直连,no-resolve",
"RULE-SET,cncidr,全局直连,no-resolve",
"RULE-SET,telegramcidr,电报消息,no-resolve",
// 其他规则
"GEOIP,LAN,全局直连,no-resolve",
"GEOIP,CN,全局直连,no-resolve",
"MATCH,漏网之鱼"
];
// 代理组通用配置
const groupBaseOption = {
"interval": 300,
"timeout": 3000,
"url": "https://www.google.com/generate_204",
"lazy": true,
"max-failed-times": 3,
"hidden": false
};
// 程序入口
function main(config) {
const proxyCount = config?.proxies?.length ?? 0;
const proxyProviderCount =
typeof config?.["proxy-providers"] === "object" ? Object.keys(config["proxy-providers"]).length : 0;
if (proxyCount === 0 && proxyProviderCount === 0) {
throw new Error("配置文件中未找到任何代理");
}
// 覆盖原配置中DNS配置
config["dns"] = dnsConfig;
// 覆盖原配置中的代理组
config["proxy-groups"] = [
{
...groupBaseOption,
"name": "节点选择",
"type": "select",
"proxies": ["延迟选优", "故障转移", "负载均衡(散列)", "负载均衡(轮询)"],
"include-all": true,
"icon": "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/adjust.svg"
},
{
...groupBaseOption,
"name": "延迟选优",
"type": "url-test",
"tolerance": 100,
"include-all": true,
"icon": "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/speed.svg"
},
{
...groupBaseOption,
"name": "故障转移",
"type": "fallback",
"include-all": true,
"icon": "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/ambulance.svg"
},
{
...groupBaseOption,
"name": "负载均衡(散列)",
"type": "load-balance",
"strategy": "consistent-hashing",
"include-all": true,
"icon": "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/merry_go.svg"
},
{
...groupBaseOption,
"name": "负载均衡(轮询)",
"type": "load-balance",
"strategy": "round-robin",
"include-all": true,
"icon": "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/balance.svg"
},
{
...groupBaseOption,
"name": "谷歌服务",
"type": "select",
"proxies": ["节点选择", "延迟选优", "故障转移", "负载均衡(散列)", "负载均衡(轮询)", "全局直连"],
"include-all": true,
"icon": "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/google.svg"
},
{
...groupBaseOption,
"name": "国外媒体",
"type": "select",
"proxies": ["节点选择", "延迟选优", "故障转移", "负载均衡(散列)", "负载均衡(轮询)", "全局直连"],
"include-all": true,
"icon": "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/youtube.svg"
},
{
...groupBaseOption,
"name": "电报消息",
"type": "select",
"proxies": ["节点选择", "延迟选优", "故障转移", "负载均衡(散列)", "负载均衡(轮询)", "全局直连"],
"include-all": true,
"icon": "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/telegram.svg"
},
{
...groupBaseOption,
"url": "https://chatgpt.com",
"expected-status": "200",
"name": "ChatGPT",
"type": "select",
"include-all": true,
"filter": "AD|🇦🇩|AE|🇦🇪|AF|🇦🇫|AG|🇦🇬|AL|🇦🇱|AM|🇦🇲|AO|🇦🇴|AR|🇦🇷|AT|🇦🇹|AU|🇦🇺|AZ|🇦🇿|BA|🇧🇦|BB|🇧🇧|BD|🇧🇩|BE|🇧🇪|BF|🇧🇫|BG|🇧🇬|BH|🇧🇭|BI|🇧🇮|BJ|🇧🇯|BN|🇧🇳|BO|🇧🇴|BR|🇧🇷|BS|🇧🇸|BT|🇧🇹|BW|🇧🇼|BZ|🇧🇿|CA|🇨🇦|CD|🇨🇩|CF|🇨🇫|CG|🇨🇬|CH|🇨🇭|CI|🇨🇮|CL|🇨🇱|CM|🇨🇲|CO|🇨🇴|CR|🇨🇷|CV|🇨🇻|CY|🇨🇾|CZ|🇨🇿|DE|🇩🇪|DJ|🇩🇯|DK|🇩🇰|DM|🇩🇲|DO|🇩🇴|DZ|🇩🇿|EC|🇪🇨|EE|🇪🇪|EG|🇪🇬|ER|🇪🇷|ES|🇪🇸|ET|🇪🇹|FI|🇫🇮|FJ|🇫🇯|FM|🇫🇲|FR|🇫🇷|GA|🇬🇦|GB|🇬🇧|GD|🇬🇩|GE|🇬🇪|GH|🇬🇭|GM|🇬🇲|GN|🇬🇳|GQ|🇬🇶|GR|🇬🇷|GT|🇬🇹|GW|🇬🇼|GY|🇬🇾|HN|🇭🇳|HR|🇭🇷|HT|🇭🇹|HU|🇭🇺|ID|🇮🇩|IE|🇮🇪|IL|🇮🇱|IN|🇮🇳|IQ|🇮🇶|IS|🇮🇸|IT|🇮🇹|JM|🇯🇲|JO|🇯🇴|JP|🇯🇵|KE|🇰🇪|KG|🇰🇬|KH|🇰🇭|KI|🇰🇮|KM|🇰🇲|KN|🇰🇳|KR|🇰🇷|KW|🇰🇼|KZ|🇰🇿|LA|🇱🇦|LB|🇱🇧|LC|🇱🇨|LI|🇱🇮|LK|🇱🇰|LR|🇱🇷|LS|🇱🇸|LT|🇱🇹|LU|🇱🇺|LV|🇱🇻|LY|🇱🇾|MA|🇲🇦|MC|🇲🇨|MD|🇲🇩|ME|🇲🇪|MG|🇲🇬|MH|🇲🇭|MK|🇲🇰|ML|🇲🇱|MM|🇲🇲|MN|🇲🇳|MR|🇲🇷|MT|🇲🇹|MU|🇲🇺|MV|🇲🇻|MW|🇲🇼|MX|🇲🇽|MY|🇲🇾|MZ|🇲🇿|NA|🇳🇦|NE|🇳🇪|NG|🇳🇬|NI|🇳🇮|NL|🇳🇱|NO|🇳🇴|NP|🇳🇵|NR|🇳🇷|NZ|🇳🇿|OM|🇴🇲|PA|🇵🇦|PE|🇵🇪|PG|🇵🇬|PH|🇵🇭|PK|🇵🇰|PL|🇵🇱|PS|🇵🇸|PT|🇵🇹|PW|🇵🇼|PY|🇵🇾|QA|🇶🇦|RO|🇷🇴|RS|🇷🇸|RW|🇷🇼|SA|🇸🇦|SB|🇸🇧|SC|🇸🇨|SD|🇸🇩|SE|🇸🇪|SG|🇸🇬|SI|🇸🇮|SK|🇸🇰|SL|🇸🇱|SM|🇸🇲|SN|🇸🇳|SO|🇸🇴|SR|🇸🇷|SS|🇸🇸|ST|🇸🇹|SV|🇸🇻|SZ|🇸🇿|TD|🇹🇩|TG|🇹🇬|TH|🇹🇭|TJ|🇹🇯|TL|🇹🇱|TM|🇹🇲|TN|🇹🇳|TO|🇹🇴|TR|🇹🇷|TT|🇹🇹|TV|🇹🇻|TW|🇹🇼|TZ|🇹🇿|UA|🇺🇦|UG|🇺🇬|US|🇺🇸|UY|🇺🇾|UZ|🇺🇿|VA|🇻🇦|VC|🇻🇨|VN|🇻🇳|VU|🇻🇺|WS|🇼🇸|YE|🇾🇪|ZA|🇿🇦|ZM|🇿🇲|ZW|🇿🇼",
"icon": "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/chatgpt.svg"
},
{
...groupBaseOption,
"name": "微软服务",
"type": "select",
"proxies": ["全局直连", "节点选择", "延迟选优", "故障转移", "负载均衡(散列)", "负载均衡(轮询)"],
"include-all": true,
"icon": "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/microsoft.svg"
},
{
...groupBaseOption,
"name": "苹果服务",
"type": "select",
"proxies": ["节点选择", "延迟选优", "故障转移", "负载均衡(散列)", "负载均衡(轮询)", "全局直连"],
"include-all": true,
"icon": "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/apple.svg"
},
{
...groupBaseOption,
"name": "广告过滤",
"type": "select",
"proxies": ["REJECT", "DIRECT"],
"icon": "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/bug.svg"
},
{
...groupBaseOption,
"name": "全局直连",
"type": "select",
"proxies": ["DIRECT", "节点选择", "延迟选优", "故障转移", "负载均衡(散列)", "负载均衡(轮询)"],
"include-all": true,
"icon": "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/link.svg"
},
{
...groupBaseOption,
"name": "全局拦截",
"type": "select",
"proxies": ["REJECT", "DIRECT"],
"icon": "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/block.svg"
},
{
...groupBaseOption,
"name": "漏网之鱼",
"type": "select",
"proxies": ["节点选择", "延迟选优", "故障转移", "负载均衡(散列)", "负载均衡(轮询)", "全局直连"],
"include-all": true,
"icon": "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/fish.svg"
}
];
// 覆盖原配置中的规则
config["rule-providers"] = ruleProviders;
config["rules"] = rules;
// 返回修改后的配置
return config;
}
来源:https://www.clashverge.dev/guide/script.html#1
修改:我把"RULE-SET,applications,全局直连"
,注释掉了,因为规则里有aria2等下载器的程序名,对于我个人使用来说,还是希望下载器通过规则来判断是否走代理,而不是直接就直连;
clash-verge全局脚本2:
/**
* @type { {name: string,gfw?: boolean,urls?: string | string[],payload?: string | string[],extraProxies?: string | string[]}[] }
*/
const proxyGrepConfig = [
{ name: "广告拦截", gfw: false, extraProxies: "REJECT", urls: "https://cdn.jsdelivr.net/gh/blackmatrix7/ios_rule_script@master/rule/Clash/AdvertisingLite/AdvertisingLite_Classical.yaml" },
{ name: "linux.do", gfw: true, payload: "DOMAIN-SUFFIX,linux.do" },
// { name: "linux.do", gfw: false, payload: ["DOMAIN-SUFFIX,linux.do","DOMAIN-SUFFIX,linux.do"] },//例子,多个规则可以用数组
{ name: "GitHub", gfw: true, urls: "https://cdn.jsdelivr.net/gh/blackmatrix7/ios_rule_script@master/rule/Clash/GitHub/GitHub.yaml" },
{
name: "YouTube", gfw: true, urls: [
"https://cdn.jsdelivr.net/gh/blackmatrix7/ios_rule_script@master/rule/Clash/YouTube/YouTube.yaml",
"https://cdn.jsdelivr.net/gh/blackmatrix7/ios_rule_script@master/rule/Clash/YouTubeMusic/YouTubeMusic.yaml"
]
},
{ name: "Google", gfw: true, urls: "https://cdn.jsdelivr.net/gh/blackmatrix7/ios_rule_script@master/rule/Clash/Google/Google.yaml" },
{ name: "Telegram", gfw: true, urls: "https://cdn.jsdelivr.net/gh/blackmatrix7/ios_rule_script@master/rule/Clash/Telegram/Telegram.yaml" },
{ name: "openAi", gfw: true, urls: "https://cdn.jsdelivr.net/gh/blackmatrix7/ios_rule_script@master/rule/Clash/OpenAI/OpenAI.yaml" },
{ name: "Netflix", gfw: true, urls: "https://cdn.jsdelivr.net/gh/blackmatrix7/ios_rule_script@master/rule/Clash/Netflix/Netflix.yaml" },
{ name: "Twitter", gfw: true, urls: "https://cdn.jsdelivr.net/gh/blackmatrix7/ios_rule_script@master/rule/Clash/Twitter/Twitter.yaml" },
{ name: "TikTok", gfw: true, urls: "https://cdn.jsdelivr.net/gh/blackmatrix7/ios_rule_script@master/rule/Clash/TikTok/TikTok.yaml" },
{ name: "Facebook", gfw: true, urls: "https://cdn.jsdelivr.net/gh/blackmatrix7/ios_rule_script@master/rule/Clash/Facebook/Facebook.yaml" },
{ name: "OneDrive", gfw: false, urls: "https://cdn.jsdelivr.net/gh/blackmatrix7/ios_rule_script@master/rule/Clash/OneDrive/OneDrive.yaml" },
{ name: "Microsoft", gfw: false, urls: "https://cdn.jsdelivr.net/gh/blackmatrix7/ios_rule_script@master/rule/Clash/Microsoft/Microsoft.yaml" },
{ name: "Steam", gfw: true, urls: "https://cdn.jsdelivr.net/gh/blackmatrix7/ios_rule_script@release/rule/Clash/Steam/Steam.yaml" },
{ name: "Cloudflare", gfw: true, urls: "https://cdn.jsdelivr.net/gh/blackmatrix7/ios_rule_script@master/rule/Clash/Cloudflare/Cloudflare.yaml" },
]
function main(config) {
const proxyProviders = config["proxy-providers"];
// 过滤代理节点
const proxies = config.proxies;
//创建域名规则组
function createRuleProviderUrl(url) {
return {
"type": "http",
"interval": 86400,
"behavior": "classical",
"format": "yaml",
"url": url
}
}
//创建payload对应的规则
function createPayloadRules(payload, name) {
const rules = [];
const payloads = Array.isArray(payload) ? payload : [payload];
for (const item of payloads) {
const p = item.split(",");
let pushIndex = p.length;
if (p[p.length - 1].toLocaleLowerCase() == "no-resolve") {
pushIndex--;
}
p.splice(pushIndex, 0, name.replaceAll(",", "-"));
rules.push(p.join(","));
}
console.log(rules);
return rules;
}
function createGfwProxyGrep(name, addProxies) {
addProxies = addProxies ? (Array.isArray(addProxies) ? addProxies : [addProxies]) : [];
return {
"name": name,
"type": "select",
"proxies": [...addProxies, "节点选择", "DIRECT"],
"include-all": true,
}
}
function createProxyGrep(name, addProxies) {
addProxies = addProxies ? (Array.isArray(addProxies) ? addProxies : [addProxies]) : [];
return {
"name": name,
"type": "select",
"proxies": [...addProxies, "DIRECT", "节点选择"],
"include-all": true,
}
}
// 区域节点组配置
const regionGroups = [
{
"name": "节点选择",
"type": "select",
"proxies": [
"🇭🇰 香港",
"🇹🇼 台湾",
"🇯🇵 日本",
"🇺🇲 美国",
"🇸🇬 新加坡",
"🌍 其他",
"🇭🇰 【负载】香港",
"🇹🇼 【负载】台湾",
"🇯🇵 【负载】日本",
"🇺🇲 【负载】美国",
"🇸🇬 【负载】新加坡",
"🌍 【负载】其他",
"DIRECT"
]
},
// 自动选择节点组
{
"name": "🇭🇰 香港",
"type": "url-test",
"url": "http://www.gstatic.com/generate_204",
"interval": 300,
"tolerance": 100,
"include-all": true,
"filter": "(?i)港|hk|hongkong|hong kong"
},
{
"name": "🇹🇼 台湾",
"type": "url-test",
"url": "http://www.gstatic.com/generate_204",
"interval": 300,
"tolerance": 100,
"include-all": true,
"filter": "(?i)台|tw|taiwan"
},
{
"name": "🇯🇵 日本",
"type": "url-test",
"url": "http://www.gstatic.com/generate_204",
"interval": 300,
"tolerance": 100,
"include-all": true,
"filter": "(?i)日本|jp|japan"
},
{
"name": "🇺🇲 美国",
"type": "url-test",
"url": "http://www.gstatic.com/generate_204",
"interval": 300,
"tolerance": 100,
"include-all": true,
"filter": "(?i)美|us|united states|america"
},
{
"name": "🇸🇬 新加坡",
"type": "url-test",
"url": "http://www.gstatic.com/generate_204",
"interval": 300,
"tolerance": 100,
"include-all": true,
"filter": "(?i)新|sg|singapore"
},
{
"name": "🌍 其他",
"type": "url-test",
"url": "http://www.gstatic.com/generate_204",
"interval": 300,
"tolerance": 100,
"include-all": true,
"filter": "(?i)^(?!.*(港|台|日|美|新|hk|tw|jp|us|sg)).*"
},
// 负载均衡节点组
{
"name": "🇭🇰 【负载】香港",
"type": "load-balance",
"strategy": "consistent-hashing",
"url": "http://www.gstatic.com/generate_204",
"interval": 300,
"tolerance": 100,
"include-all": true,
"filter": "(?i)港|hk|hongkong|hong kong"
},
{
"name": "🇹🇼 【负载】台湾",
"type": "load-balance",
"strategy": "consistent-hashing",
"url": "http://www.gstatic.com/generate_204",
"interval": 300,
"tolerance": 100,
"include-all": true,
"filter": "(?i)台|tw|taiwan"
},
{
"name": "🇯🇵 【负载】日本",
"type": "load-balance",
"strategy": "consistent-hashing",
"url": "http://www.gstatic.com/generate_204",
"interval": 300,
"tolerance": 100,
"include-all": true,
"filter": "(?i)日本|jp|japan"
},
{
"name": "🇺🇲 【负载】美国",
"type": "load-balance",
"strategy": "consistent-hashing",
"url": "http://www.gstatic.com/generate_204",
"interval": 300,
"tolerance": 100,
"include-all": true,
"filter": "(?i)美|us|united states|america"
},
{
"name": "🇸🇬 【负载】新加坡",
"type": "load-balance",
"strategy": "consistent-hashing",
"url": "http://www.gstatic.com/generate_204",
"interval": 300,
"tolerance": 100,
"include-all": true,
"filter": "(?i)新|sg|singapore"
},
{
"name": "🌍 【负载】其他",
"type": "load-balance",
"strategy": "consistent-hashing",
"url": "http://www.gstatic.com/generate_204",
"interval": 300,
"tolerance": 100,
"include-all": true,
"filter": "(?i)^(?!.*(港|台|日|美|新|hk|tw|jp|us|sg)).*"
}
];
const proxyGfwGroups = [];
const proxyGroups = [];
const ruleProviders = {};
const rules = [];
for (const { name, gfw, urls, payload, extraProxies } of proxyGrepConfig) {
if (gfw) {
proxyGfwGroups.push(createGfwProxyGrep(name, extraProxies));
} else {
proxyGroups.push(createProxyGrep(name, extraProxies));
}
if (payload) {
rules.push(...createPayloadRules(payload, name));
} else {
const urlList = urls ? (Array.isArray(urls) ? urls : [urls]) : [];
for (const index in urlList) {
const theUrl = urlList[index];
const iName = `${name}-rule${index != 0 ? `-${index}` : ''}`;
ruleProviders[iName] = createRuleProviderUrl(theUrl);
rules.push(`RULE-SET,${iName},${name}`);
}
}
}
return {
mode: "rule",
"find-process-mode": "strict",
"global-client-fingerprint": "chrome",
"unified-delay": true, //更换延迟计算方式,去除握手等额外延迟
"tcp-concurrent": true, //TCP 并发
filter: "^((?!Remain|Expired|官网|群组|节点|订阅|年|月|如需|套餐|去除|剩余|距离|测试|发布|网址|Reset).)+$",
"geox-url": {
geoip: "https://ghgo.xyz/https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geoip-lite.dat",
geosite: "https://ghgo.xyz/https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geosite.dat",
},
dns: {
enable: true,
ipv6: true,
"enhanced-mode": "fake-ip",
"fake-ip-filter": [
"*",
"+.lan",
"+.local"
],
nameserver: [
"system",
"114.114.114.114",
"223.5.5.5",
"https://dns.alidns.com/dns-query",//阿里云
"https://doh.pub/dns-query",//腾讯
],
fallback: [
"https://1.0.0.1/dns-query",//Cloudflare
"https://sky.rethinkdns.com",//rethinkdns
"https://dns.alidns.com/dns-query",//阿里云
"https://doh.pub/dns-query",//腾讯
],
"fallback-filter": {
geoip: true,
"geoip-code": "CN",
geosite: ["gfw"],
domain: [
'+.google.com',
'+.facebook.com',
'+.youtube.com',
]
}
},
//代理
proxies: proxies,
"proxy-providers": proxyProviders,
"proxy-groups": [
...regionGroups,
{
"name": "国外网站",
"type": "select",
"url": "https://www.bing.com/favicon.ico",
"proxies": ["节点选择", "DIRECT"],
"include-all": true,
},
{
"name": "被墙网站",
"type": "select",
"proxies": ["节点选择", "DIRECT"],
"include-all": true,
},
...proxyGroups,
{
"name": "国内网站",
"type": "select",
"proxies": ["DIRECT", "节点选择"],
"include-all": true,
"url": "https://www.baidu.com/favicon.ico"
},
...proxyGfwGroups
],
"rule-providers": ruleProviders,
rules: [
...rules,
"GEOSITE,gfw,被墙网站",
"GEOIP,CN,国内网站",
"MATCH,国外网站"
]
};
}
功能介绍
我把自用的分流规则都封装到这个脚本里了,并且还可以超方便的添加和删除分流规则。可以不同网站选择不同的节点,实现很多骚操作。
比如openai这种挑节点的可以单独分流用好一点的节点代理,像谷歌这种啥ip都能用的就用便宜节点,还有NetFlix解锁用解锁节点。
增加两个功能:
自动选择最低延迟和负载均衡区分了国家
增加了Telegram规则
- THE END -
最后修改:2025年1月21日
非特殊说明,本博所有文章均为博主原创。
如若转载,请注明出处:https://baiyakai.com/493.html
共有 0 条评论