Last active
May 1, 2024 09:03
-
-
Save yanyongyu/76cf3a4a094fc07c89b682c4c8604a57 to your computer and use it in GitHub Desktop.
Clash For Windows parser for replacing rules
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
parsers: | |
- reg: ^.*$ | |
code: > | |
module.exports.parse = async (raw, { yaml }) => { | |
const profile = yaml.parse(raw); | |
const proxies = profile.proxies; | |
const proxyNames = proxies.map((proxy) => proxy.name); | |
const proxyGroups = [ | |
{ | |
name: "π§ 樑εΌεζ’", | |
type: "select", | |
proxies: ["π θηΉιζ©", "DIRECT"], | |
}, | |
{ | |
name: "π θηΉιζ©", | |
type: "select", | |
proxies: proxyNames, | |
}, | |
{ | |
name: "π― ε ¨ηη΄θΏ", | |
type: "select", | |
proxies: ["DIRECT", "π§ 樑εΌεζ’"], | |
}, | |
{ | |
name: "π ε ¨ηζ¦ζͺ", | |
type: "select", | |
proxies: ["REJECT", "DIRECT", "π§ 樑εΌεζ’"], | |
}, | |
{ | |
name: "π ζΌη½δΉι±Ό", | |
type: "select", | |
proxies: ["DIRECT", "π§ 樑εΌεζ’"], | |
}, | |
]; | |
const ruleProviders = { | |
direct: { | |
type: "http", | |
behavior: "domain", | |
url: "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/direct.txt", | |
path: "./ruleset/direct.yaml", | |
interval: 86400, | |
}, | |
proxy: { | |
type: "http", | |
behavior: "domain", | |
url: "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/proxy.txt", | |
path: "./ruleset/proxy.yaml", | |
interval: 86400, | |
}, | |
reject: { | |
type: "http", | |
behavior: "domain", | |
url: "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/reject.txt", | |
path: "./ruleset/reject.yaml", | |
interval: 86400, | |
}, | |
icloud: { | |
type: "http", | |
behavior: "domain", | |
url: "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/icloud.txt", | |
path: "./ruleset/icloud.yaml", | |
interval: 86400, | |
}, | |
apple: { | |
type: "http", | |
behavior: "domain", | |
url: "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/apple.txt", | |
path: "./ruleset/apple.yaml", | |
interval: 86400, | |
}, | |
google: { | |
type: "http", | |
behavior: "domain", | |
url: "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/google.txt", | |
path: "./ruleset/google.yaml", | |
interval: 86400, | |
}, | |
private: { | |
type: "http", | |
behavior: "domain", | |
url: "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/private.txt", | |
path: "./ruleset/private.yaml", | |
interval: 86400, | |
}, | |
gfw: { | |
type: "http", | |
behavior: "domain", | |
url: "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/gfw.txt", | |
path: "./ruleset/gfw.yaml", | |
interval: 86400, | |
}, | |
"tld-not-cn": { | |
type: "http", | |
behavior: "domain", | |
url: "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/tld-not-cn.txt", | |
path: "./ruleset/tld-not-cn.yaml", | |
interval: 86400, | |
}, | |
telegramcidr: { | |
type: "http", | |
behavior: "ipcidr", | |
url: "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/telegramcidr.txt", | |
path: "./ruleset/telegramcidr.yaml", | |
interval: 86400, | |
}, | |
cncidr: { | |
type: "http", | |
behavior: "ipcidr", | |
url: "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/cncidr.txt", | |
path: "./ruleset/cncidr.yaml", | |
interval: 86400, | |
}, | |
lancidr: { | |
type: "http", | |
behavior: "ipcidr", | |
url: "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/lancidr.txt", | |
path: "./ruleset/lancidr.yaml", | |
interval: 86400, | |
}, | |
applications: { | |
type: "http", | |
behavior: "classical", | |
url: "https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/applications.txt", | |
path: "./ruleset/applications.yaml", | |
interval: 86400, | |
}, | |
}; | |
const rules = [ | |
"RULE-SET,applications,π― ε ¨ηη΄θΏ", | |
"DOMAIN,clash.razord.top,π― ε ¨ηη΄θΏ", | |
"DOMAIN,yacd.haishan.me,π― ε ¨ηη΄θΏ", | |
"RULE-SET,private,π― ε ¨ηη΄θΏ", | |
"RULE-SET,reject,π ε ¨ηζ¦ζͺ", | |
"RULE-SET,icloud,π― ε ¨ηη΄θΏ", | |
"RULE-SET,apple,π― ε ¨ηη΄θΏ", | |
"RULE-SET,google,π― ε ¨ηη΄θΏ", | |
"RULE-SET,proxy,π§ 樑εΌεζ’", | |
"RULE-SET,direct,π― ε ¨ηη΄θΏ", | |
"RULE-SET,lancidr,π― ε ¨ηη΄θΏ", | |
"RULE-SET,cncidr,π― ε ¨ηη΄θΏ", | |
"RULE-SET,telegramcidr,π§ 樑εΌεζ’", | |
"GEOIP,LAN,π― ε ¨ηη΄θΏ", | |
"GEOIP,CN,π― ε ¨ηη΄θΏ", | |
"MATCH,π ζΌη½δΉι±Ό", | |
]; | |
return yaml.stringify({ | |
...profile, | |
"proxy-groups": proxyGroups, | |
"rule-providers": ruleProviders, | |
rules, | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment