Skip to content

Instantly share code, notes, and snippets.

@xgdgsc
Last active May 1, 2023 00:50
Show Gist options
  • Save xgdgsc/848cb7a643521987e378cbd0f025fd07 to your computer and use it in GitHub Desktop.
Save xgdgsc/848cb7a643521987e378cbd0f025fd07 to your computer and use it in GitHub Desktop.
clash filter auto switch load-balance example
parsers: # array
- url: YOUR_URL
code: |
module.exports.parse = (raw,{ yaml }) => {
const rawObj = yaml.parse(raw)
var proxy_groups = rawObj["proxy-groups"]
var valid_arr = []
var select_i = 0
for(var i = 0; i < proxy_groups.length; i++) {
var obj = proxy_groups[i];
if(obj["name"].localeCompare("♻️ 自动选择")==0){
for(var j=0;j<obj["proxies"].length;j++){
if(obj["proxies"][j].indexOf("X10")==-1){
valid_arr.push(obj["proxies"][j])
console.log(obj["proxies"][j])
}
}
obj["proxies"] = valid_arr
}
}
rawObj["proxy-groups"].push({
"name": "LoadBalance",
"type": "load-balance",
"proxies": valid_arr,
"url": "http://www.gstatic.com/generate_204",
"interval": 60
})
rawObj["proxy-groups"][0]["proxies"].unshift("LoadBalance")
var result = yaml.stringify(rawObj)
console.log(result)
return result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment