MCPcopy Create free account
hub / github.com/Moli-X/Resources / overwriteProxyGroups

Function overwriteProxyGroups

Clash/Script/Script.js:173–322  ·  view source on GitHub ↗
(params)

Source from the content-addressed store, hash-verified

171
172//覆写代理组
173function overwriteProxyGroups(params) {
174 // 所有代理
175 const allProxies = params["proxies"].map((e) => e.name);
176 // 自动选择代理组,按地区分组选延迟最低
177 const autoProxyGroupRegexs = [
178 { name: "HK-自动选择", regex: /香港|HK|Hong|🇭🇰/ },
179 { name: "TW-自动选择", regex: /台湾|TW|Taiwan|Wan|🇨🇳|🇹🇼/ },
180 { name: "SG-自动选择", regex: /新加坡|狮城|SG|Singapore|🇸🇬/ },
181 { name: "JP-自动选择", regex: /日本|JP|Japan|🇯🇵/ },
182 { name: "US-自动选择", regex: /美国|US|United States|America|🇺🇸/ },
183 { name: "其它-自动选择", regex: /(?!.*(?:剩余|到期|主页|官网|游戏|关注))(.*)/ },
184 ];
185
186 const autoProxyGroups = autoProxyGroupRegexs
187 .map((item) => ({
188 name: item.name,
189 type: "url-test",
190 url: "http://www.gstatic.com/generate_204",
191 interval: 300,
192 tolerance: 50,
193 proxies: getProxiesByRegex(params, item.regex),
194 hidden: true,
195 }))
196 .filter((item) => item.proxies.length > 0);
197
198 //手工选择代理组
199 const manualProxyGroups = [
200 { name: "HK-手工选择", regex: /香港|HK|Hong|🇭🇰/, icon: "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/flags/hk.svg" },
201 { name: "TW-手工选择", regex: /台湾|TW|Taiwan|Wan|🇨🇳|🇹🇼/, icon: "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/flags/tw.svg" },
202 { name: "SG-手工选择", regex: /新加坡|狮城|SG|Singapore|🇸🇬/, icon: "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/flags/sg.svg" },
203 { name: "JP-手工选择", regex: /日本|JP|Japan|🇯🇵/, icon: "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/flags/jp.svg" },
204 { name: "US-手工选择", regex: /美国|US|United States|America|🇺🇸/, icon: "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/flags/us.svg" },
205 ];
206
207 const manualProxyGroupsConfig = manualProxyGroups
208 .map((item) => ({
209 name: item.name,
210 type: "select",
211 proxies: getManualProxiesByRegex(params, item.regex),
212 icon: item.icon,
213 hidden: false,
214 }))
215 .filter((item) => item.proxies.length > 0);
216
217 const groups = [
218 {
219 name: proxyName,
220 type: "select",
221 url: "http://www.gstatic.com/generate_204",
222 icon: "https://fastly.jsdelivr.net/gh/clash-verge-rev/clash-verge-rev.github.io@main/docs/assets/icons/adjust.svg",
223 proxies: [
224 "自动选择",
225 "手动选择",
226 "负载均衡(散列)",
227 "负载均衡(轮询)",
228 "DIRECT",
229 ],
230 },

Callers 1

mainFunction · 0.70

Calls 3

getManualProxiesByRegexFunction · 0.85
getProxiesByRegexFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected