Introduction#
After Clash for Windows deleted its repository and went offline, Clash Verge became the mainstream choice for the public (this does not mean that Clash for Windows is unusable, just that there are no further updates). After switching to this software, I found that it surprisingly lacks the Parsers feature, which I found very regrettable.
So I found a solution to add a similar Parsers feature to Clash Verge through the configuration file of Clash Verge.
Configuration File (Personal Modified Version, Only Implements Simple Functionality)#
Script Section#
// Define the `main` function
// function main(params) {
// return params;
// }
// Define the `main` function
function main(params) {
// All Regions
const allRegex = /automatic|failure|traffic|official website|package|airport|subscription/;
const allProxies = params.proxies
.filter((e) => !allRegex.test(e.name))
.map((e) => e.name);
// Node Selection
const Proxy = {
name: "Proxy",
type: "select",
proxies: allProxies.length > 0 ? allProxies : ["DIRECT"]
};
// Failover
const Speedtest = {
name: "Speedtest",
type: "select",
proxies: allProxies.length > 0 ? allProxies : ["DIRECT"]
};
const groups = params["proxy-groups"] = [];
// Rules
const rules = [
"AND,(AND,(DST-PORT,443),(NETWORK,UDP)),(NOT,((GEOIP,CN))),REJECT",// quic
// "GEOSITE,Category-ads-all,REJECT", // May cause some websites to be inaccessible
"GEOSITE,sogou,REJECT",
"GEOSITE,qihoo360,REJECT",
"DOMAIN,b23.tv,REJECT",
"DOMAIN-SUFFIX,db.laomoe.com,Speedtest",
"GEOSITE,speedtest,Speedtest",
"GEOSITE,category-scholar-!cn,Proxy",
"GEOSITE,youtube,Proxy",
"GEOSITE,google,Proxy",
"GEOSITE,bilibili@!cn,Proxy",
"GEOSITE,cn,DIRECT",
"GEOSITE,private,DIRECT",
"GEOSITE,steam@cn,DIRECT",
"GEOSITE,category-games@cn,DIRECT",
"GEOSITE,geolocation-!cn,Proxy",
"GEOSITE,private,DIRECT",
"GEOSITE,telegram,Proxy",
"GEOIP,private,DIRECT,no-resolve",
"GEOIP,telegram,Proxy,no-resolve",
"GEOIP,CN,DIRECT",
"DOMAIN-SUFFIX,.cn,DIRECT",
"MATCH,Proxy"
];
// Insert Groups
groups.unshift(Proxy, Speedtest)
// Insert Rules
params.rules = rules;
return params;
}
Merge Section#
# Merge Template for clash verge
# The `Merge` format used to enhance profile
mode: rule # Rule mode: rule / global / direct / script
ipv6: true # Enable IPv6 switch, disable blocking all IPv6 connections and blocking DNS requests for AAAA records
log-level: info # Set log output level (5 levels: silent / error / warning / info / debug)
mixed-port: 20810 # Mixed port, HTTP and SOCKS5 use one port
unified-delay: true # Unified delay, change delay calculation method, remove extra delays like handshake
tcp-concurrent: true # [Meta exclusive] TCP concurrent connections to all IPs, will use the fastest handshake TCP
keep-alive-interval: 15 # TCP keep alive interval
geodata-mode: true # [Meta exclusive] Use geoip.dat database (default: false uses mmdb database)
geox-url: # Custom geodata url, requires a proxy to download geoip and geosite
geoip: "https://gcore.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@release/geoip.dat"
geosite: "https://gcore.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@release/geosite.dat"
mmdb: "https://gcore.jsdelivr.net/gh/Hackl0us/GeoIP2-CN@release/Country.mmdb"
find-process-mode: strict # Match all processes (always/strict/off)
global-client-fingerprint: chrome # Global TLS fingerprint, priority lower than client-fingerprint in proxy
# Optional: "chrome","firefox","safari","ios","random","none" options.
profile:
store-selected: true # Store select choice records
store-fake-ip: true # Persist fake-ip
sniffer: # Sniff domain optional configuration
enable: true
parse-pure-ip: true # Whether to use sniffing results as actual access, default true
sniff:
TLS: # TLS default sniffing 443
ports: [443, 8443]
HTTP:
ports: [80, 8080-8880]
override-destination: true
force-domain: [] # Force sniffing for this domain
dns:
enable: true # Close will use system DNS
prefer-h3: true # Whether to enable DOH's http/3
ipv6: true # IPV6 resolution switch; if false, will return empty ipv6 results
enhanced-mode: fake-ip # Mode: redir-host or fake-ip
listen: 0.0.0.0:1053 # DNS listening address
use-hosts: true # Whether to query system hosts
fake-ip-range: 198.18.0.1/16 # Fake IP range settings, the default IP of the tun network card also uses this value
fake-ip-filter: ['+.lan', '+.msftncsi.com', 'msftconnecttest.com', '+.msftconnecttest.com', '*.msftncsi.com', '*.msftconnecttest.com']
# Fake-ip filtering, domain names in the list return real IP
default-nameserver: [223.5.5.5, 119.29.29.29]
# DNS servers used for resolving non-IP DNS, supports pure IP only, (Meta can encrypt it)
nameserver: [tcp://208.67.222.222#Proxy, tcp://8.8.8.8#Proxy]
# Default DNS servers, supports udp/tcp/dot/doh/doq
proxy-server-nameserver: [https://223.5.5.5/dns-query, https://1.12.12.12/dns-query]
# Proxy DNS servers, supports udp/tcp/dot/doh/doq
nameserver-policy:
"geosite:cn,private,geolocation-!cn@cn,bytedance,steam@cn,epicgames,microsoft@cn,apple@cn": [223.5.5.5#DIRECT, 119.29.29.29#DIRECT]
"geosite:steam": [tcp://1.1.1.1#Proxy]
# Specify the resolution server for domain name queries, can use geosite, priority over nameserver/fallback queries
Original Configuration File by Experts (Realizes Multi-Region Multi-Platform Traffic Distribution)#
Script Section#
// Define the `main` function
// function main(params) {
// return params;
// }
// Define the `main` function
function main(params) {
// Hong Kong Region
const hongKongRegex = /Hong Kong|HK|Hong|🇭🇰/;
const hongKongProxies = params.proxies
.filter((e) => hongKongRegex.test(e.name))
.map((e) => e.name);
// Taiwan Region
const taiwanRegex = /Taiwan|TW|Taiwan|Wan|🇨🇳|🇹🇼/;
const taiwanProxies = params.proxies
.filter((e) => taiwanRegex.test(e.name))
.map((e) => e.name);
// Lion City Region
const singaporeRegex = /Singapore|Lion City|SG|Singapore|🇸🇬/;
const singaporeProxies = params.proxies
.filter((e) => singaporeRegex.test(e.name))
.map((e) => e.name);
// Japan Region
const japanRegex = /Japan|JP|Japan|🇯🇵/;
const japanProxies = params.proxies
.filter((e) => japanRegex.test(e.name))
.map((e) => e.name);
// United States Region
const americaRegex = /United States|US|United States|America|🇺🇸/;
const americaProxies = params.proxies
.filter((e) => americaRegex.test(e.name))
.map((e) => e.name);
// Other Regions
const othersRegex = /Hong Kong|HK|Hong|🇭🇰|Taiwan|TW|Taiwan|Wan|🇨🇳|🇹🇼|Singapore|SG|Singapore|Lion City|🇸🇬|Japan|JP|Japan|🇯🇵|United States|US|States|America|🇺🇸|automatic|failure|traffic|official website|package|airport|subscription/;
const othersProxies = params.proxies
.filter((e) => !othersRegex.test(e.name))
.map((e) => e.name);
// All Regions
const allRegex = /automatic|failure|traffic|official website|package|airport|subscription/;
const allProxies = params.proxies
.filter((e) => !allRegex.test(e.name))
.map((e) => e.name);
// Hong Kong
const HongKong = {
name: "HongKong",
type: "url-test",
url: "http://www.gstatic.com/generate_204",
interval: 300,
tolerance: 20,
lazy: true,
proxies: hongKongProxies.length > 0 ? hongKongProxies : ["DIRECT"]
};
// Taiwan
const TaiWan = {
name: "TaiWan",
type: "url-test",
url: "http://www.gstatic.com/generate_204",
interval: 300,
tolerance: 20,
lazy: true,
proxies: taiwanProxies.length > 0 ? taiwanProxies : ["DIRECT"]
};
// Lion City
const Singapore = {
name: "Singapore",
type: "url-test",
url: "http://www.gstatic.com/generate_204",
interval: 300,
tolerance: 20,
lazy: true,
proxies: singaporeProxies.length > 0 ? singaporeProxies : ["DIRECT"]
};
// Japan
const Japan = {
name: "Japan",
type: "url-test",
url: "http://www.gstatic.com/generate_204",
interval: 300,
tolerance: 20,
lazy: true,
proxies: japanProxies.length > 0 ? japanProxies : ["DIRECT"]
};
// United States
const America = {
name: "America",
type: "url-test",
url: "http://www.gstatic.com/generate_204",
interval: 300,
tolerance: 20,
lazy: true,
proxies: americaProxies.length > 0 ? americaProxies : ["DIRECT"]
};
// Others
const Others = {
name: "Others",
type: "url-test",
url: "http://www.gstatic.com/generate_204",
interval: 300,
tolerance: 20,
lazy: true,
proxies: othersProxies.length > 0 ? othersProxies : ["DIRECT"]
};
// Automatic
const Auto = {
name: "Auto",
type: "url-test",
url: "http://www.gstatic.com/generate_204",
interval: 300,
tolerance: 20,
lazy: true,
proxies: allProxies.length > 0 ? allProxies : ["DIRECT"]
};
// Load Balancing
const Balance = {
name: "Balance",
type: "load-balance",
url: "http://www.gstatic.com/generate_204",
interval: 300,
strategy: "consistent-hashing",
lazy: true,
proxies: allProxies.length > 0 ? allProxies : ["DIRECT"]
};
// Failover
const Fallback = {
name: "Fallback",
type: "fallback",
url: "http://www.gstatic.com/generate_204",
interval: 300,
lazy: true,
proxies: allProxies.length > 0 ? allProxies : ["DIRECT"]
};
// Foreign Groups
const G = ["Proxy", "Auto", "Balance", "Fallback", "HongKong", "TaiWan", "Singapore", "Japan", "America", "Others"];
// Domestic Groups
const M = ["DIRECT", "Proxy", "Auto", "Balance", "Fallback", "HongKong", "TaiWan", "Singapore", "Japan", "America", "Others"];
// AI Groups
const AI = ["Proxy", "America", "Japan", "Singapore", "TaiWan", "HongKong", "Others"];
// Last Resort
const Final = { name: "Final", type: "select", proxies: ["DIRECT", "Global", "Proxy"] };
// Manual Selection
const Proxy = { name: "Proxy", type: "select", proxies: allProxies.length > 0 ? allProxies : ["DIRECT"] };
// Foreign Websites
const Global = { name: "Global", type: "select", proxies: G };
// Domestic Websites
const Mainland = { name: "Mainland", type: "select", proxies: M };
// Artificial Intelligence
const ArtIntel = { name: "ArtIntel", type: "select", proxies: AI };
// YouTube Videos
const YouTube = { name: "YouTube", type: "select", proxies: G };
// Bilibili
const BiliBili = { name: "BiliBili", type: "select", proxies: ["DIRECT", "HongKong", "TaiWan"] };
// International Media
const Streaming = { name: "Streaming", type: "select", proxies: G };
// Telegram Information
const Telegram = { name: "Telegram", type: "select", proxies: G };
// Google Services
const Google = { name: "Google", type: "select", proxies: G };
// Gaming Platforms
const Games = { name: "Games", type: "select", proxies: G };
const groups = params["proxy-groups"] = [];
// Rules
const rules = [
"AND,(AND,(DST-PORT,443),(NETWORK,UDP)),(NOT,((GEOIP,CN))),REJECT",// quic
// "GEOSITE,Category-ads-all,REJECT", // May cause some websites to be inaccessible
"GEOSITE,Private,DIRECT",
"GEOSITE,Category-games@cn,Mainland",
"GEOSITE,Microsoft@cn,Mainland",
"GEOSITE,Apple@cn,Mainland",
"GEOSITE,Bing,ArtIntel",
"GEOSITE,Openai,ArtIntel",
"GEOSITE,Category-games,Games",
"GEOSITE,Github,Global",
"GEOSITE,Telegram,Telegram",
"GEOSITE,Youtube,YouTube",
"GEOSITE,Disney,Streaming",
"GEOSITE,Netflix,Streaming",
"GEOSITE,HBO,Streaming",
"GEOSITE,Primevideo,Streaming",
"GEOSITE,Bilibili,BiliBili",
"GEOSITE,Google,Google",
"GEOSITE,Geolocation-!cn,Global",
"GEOIP,CN,Mainland,no-resolve",
"MATCH,Final"
];
// Insert Groups
groups.unshift(HongKong, TaiWan, Japan, Singapore, America, Others, Auto, Balance, Fallback);
groups.unshift(Final, Proxy, Global, Mainland, ArtIntel, YouTube, BiliBili, Streaming, Telegram, Google, Games);
// Insert Rules
params.rules = rules;
return params;
}