forked from Repcz/Tool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOverride.js
380 lines (368 loc) · 12.6 KB
/
Override.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
// 参考 Verge Rev 示例 Script 配置
//
// Clash Verge Rev (Version ≥ 17.2) & Mihomo-Party (Version ≥ 1.5.10)
//
// 最后更新时间: 2024-11-17 20:45
// 规则集通用配置
const ruleProviderCommon = {
"type": "http",
"format": "text",
"interval": 86400
};
// 策略组通用配置
const groupBaseOption = {
"interval": 300,
"url": "http://1.1.1.1/generate_204",
"max-failed-times": 3,
};
// 程序入口
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("配置文件中未找到任何代理");
}
// 覆盖通用配置
config["mixed-port"] = "7890";
config["tcp-concurrent"] = true;
config["allow-lan"] = true;
config["ipv6"] = false;
config["log-level"] = "info";
config["unified-delay"] = "true";
config["find-process-mode"] = "strict";
config["global-client-fingerprint"] = "chrome";
// 覆盖 dns 配置
config["dns"] = {
"enable": true,
"listen": "0.0.0.0:1053",
"ipv6": false,
"enhanced-mode": "fake-ip",
"fake-ip-range": "198.18.0.1/16",
"fake-ip-filter": ["*", "+.lan", "+.local", "+.direct", "+.msftconnecttest.com", "+.msftncsi.com"],
"nameserver": ["223.5.5.5", "119.29.29.29"],
"nameserver-policy": {"rule-set:AD": "rcode://success"}
};
// 覆盖 geodata 配置
config["geodata-mode"] = true;
config["geox-url"] = {
"geoip": "https://mirror.ghproxy.com/https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geoip-lite.dat",
"geosite": "https://mirror.ghproxy.com/https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geosite.dat",
"mmdb": "https://mirror.ghproxy.com/https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/country-lite.mmdb",
"asn": "https://mirror.ghproxy.com/https://github.com/xishang0128/geoip/releases/download/latest/GeoLite2-ASN.mmdb"
};
// 覆盖 sniffer 配置
config["sniffer"] = {
"enable": true,
"parse-pure-ip": true,
"sniff": {
"TLS": {
"ports": ["443", "8443"]
},
"HTTP": {
"ports": ["80", "8080-8880"],
"override-destination": true
},
"QUIC": {
"ports": ["443", "8443"]
}
}
};
// 覆盖 tun 配置
config["tun"] = {
"enable": true,
"stack": "mixed",
"dns-hijack": ["any:53"]
};
// 覆盖策略组
config["proxy-groups"] = [
{
...groupBaseOption,
"name": "手动切换",
"type": "select",
"proxies": ["香港节点", "美国节点", "狮城节点", "日本节点", "台湾节点", "DIRECT"],
"include-all": true,
"icon": "https://github.com/shindgewongxj/WHATSINStash/raw/main/icon/applesafari.png"
},
{
...groupBaseOption,
"name": "国外网站",
"type": "select",
"proxies": ["手动切换", "香港节点", "美国节点", "狮城节点", "日本节点", "台湾节点", "DIRECT"],
"icon": "https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/Color/Global.png"
},
{
...groupBaseOption,
"name": "国际媒体",
"type": "select",
"proxies": ["手动切换", "香港节点", "美国节点", "狮城节点", "日本节点", "台湾节点", "DIRECT"],
"icon": "https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/Color/YouTube.png"
},
{
...groupBaseOption,
"name": "苹果服务",
"type": "select",
"proxies": ["手动切换", "香港节点", "美国节点", "狮城节点", "日本节点", "台湾节点", "DIRECT"],
"icon": "https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/Color/Apple_1.png"
},
{
...groupBaseOption,
"name": "微软服务",
"type": "select",
"proxies": ["手动切换", "香港节点", "美国节点", "狮城节点", "日本节点", "台湾节点", "DIRECT"],
"icon": "https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/Color/Microsoft.png"
},
{
...groupBaseOption,
"name": "谷歌服务",
"type": "select",
"proxies": ["手动切换", "香港节点", "美国节点", "狮城节点", "日本节点", "台湾节点", "DIRECT"],
"icon": "https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/Color/Google_Search.png"
},
{
...groupBaseOption,
"name": "电报消息",
"type": "select",
"proxies": ["手动切换", "香港节点", "美国节点", "狮城节点", "日本节点", "台湾节点", "DIRECT"],
"icon": "https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/Color/Telegram.png"
},
{
...groupBaseOption,
"name": "推特消息",
"type": "select",
"proxies": ["手动切换", "香港节点", "美国节点", "狮城节点", "日本节点", "台湾节点", "DIRECT"],
"icon": "https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/Color/Twitter.png"
},
{
...groupBaseOption,
"name": "AI",
"type": "select",
"proxies": ["手动切换", "香港节点", "美国节点", "狮城节点", "日本节点", "台湾节点", "DIRECT"],
"icon": "https://raw.githubusercontent.com/Orz-3/mini/master/Color/OpenAI.png"
},
{
...groupBaseOption,
"name": "游戏平台",
"type": "select",
"proxies": ["手动切换", "香港节点", "美国节点", "狮城节点", "日本节点", "台湾节点", "DIRECT"],
"icon": "https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/Color/Game.png"
},
{
...groupBaseOption,
"name": "Emby",
"type": "select",
"include-all": true,
"proxies": ["手动切换", "香港节点", "美国节点", "狮城节点", "日本节点", "台湾节点", "DIRECT"],
"icon": "https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/Color/Emby.png"
},
{
...groupBaseOption,
"name": "兜底分流",
"type": "select",
"proxies": ["手动切换", "香港节点", "美国节点", "狮城节点", "日本节点", "台湾节点", "DIRECT"],
"icon": "https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/Color/Final.png"
},
// 地区分组
{
...groupBaseOption,
"name": "香港节点",
"type": "url-test",
"tolerance": 0,
"include-all": true,
"filter": "(?i)🇭🇰|香港|(\b(HK|Hong)\b)",
"icon": "https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/Color/Hong_Kong.png"
},
{
...groupBaseOption,
"name": "美国节点",
"type": "url-test",
"tolerance": 0,
"include-all": true,
"filter": "(?i)🇺🇸|美国|洛杉矶|圣何塞|(\b(US|United States)\b)",
"icon": "https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/Color/United_States.png"
},
{
...groupBaseOption,
"name": "狮城节点",
"type": "url-test",
"tolerance": 0,
"include-all": true,
"filter": "(?i)🇸🇬|新加坡|狮|(\b(SG|Singapore)\b)",
"icon": "https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/Color/Singapore.png"
},
{
...groupBaseOption,
"name": "日本节点",
"type": "url-test",
"tolerance": 0,
"include-all": true,
"filter": "(?i)🇯🇵|日本|东京|(\b(JP|Japan)\b)",
"icon": "https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/Color/Japan.png"
},
{
...groupBaseOption,
"name": "台湾节点",
"type": "url-test",
"tolerance": 0,
"include-all": true,
"filter": "(?i)🇨🇳|🇹🇼|台湾|(\b(TW|Tai|Taiwan)\b)",
"icon": "https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/Color/China.png"
}
];
// 覆盖规则集
config["rule-providers"] = {
"AD": {
...ruleProviderCommon,
"behavior": "classical",
"url": "https://github.com/Repcz/Tool/raw/X/Clash/Rules/Reject.list",
"path": "./rules/AD.list"
},
"Apple": {
...ruleProviderCommon,
"behavior": "classical",
"url": "https://github.com/Repcz/Tool/raw/X/Clash/Rules/Apple.list",
"path": "./rules/Apple.list"
},
"Google": {
...ruleProviderCommon,
"behavior": "classical",
"url": "https://github.com/Repcz/Tool/raw/X/Clash/Rules/Google.list",
"path": "./rules/Google.list"
},
"YouTube": {
...ruleProviderCommon,
"behavior": "classical",
"url": "https://github.com/Repcz/Tool/raw/X/Clash/Rules/YouTube.list",
"path": "./rules/YouTube.list"
},
"Telegram": {
...ruleProviderCommon,
"behavior": "classical",
"url": "https://github.com/Repcz/Tool/raw/X/Clash/Rules/Telegram.list",
"path": "./rules/Telegram.list"
},
"Twitter": {
...ruleProviderCommon,
"behavior": "classical",
"url": "https://github.com/Repcz/Tool/raw/X/Clash/Rules/Twitter.list",
"path": "./rules/Twitter.list"
},
"Steam": {
...ruleProviderCommon,
"behavior": "classical",
"url": "https://github.com/Repcz/Tool/raw/X/Clash/Rules/Steam.list",
"path": "./rules/Steam.list"
},
"Epic": {
...ruleProviderCommon,
"behavior": "classical",
"url": "https://github.com/Repcz/Tool/raw/X/Clash/Rules/Epic.list",
"path": "./rules/Epic.list"
},
"AI": {
...ruleProviderCommon,
"behavior": "classical",
"url": "https://github.com/Repcz/Tool/raw/X/Clash/Rules/AI.list",
"path": "./rules/AI.list"
},
"Emby": {
...ruleProviderCommon,
"behavior": "classical",
"url": "https://github.com/Repcz/Tool/raw/X/Clash/Rules/Emby.list",
"path": "./rules/Emby.list"
},
"Spotify": {
...ruleProviderCommon,
"behavior": "classical",
"url": "https://github.com/Repcz/Tool/raw/X/Clash/Rules/Spotify.list",
"path": "./rules/Spotify.list"
},
"Bahamut": {
...ruleProviderCommon,
"behavior": "classical",
"url": "https://github.com/Repcz/Tool/raw/X/Clash/Rules/Bahamut.list",
"path": "./rules/Bahamut.list"
},
"Netflix": {
...ruleProviderCommon,
"behavior": "classical",
"url": "https://github.com/Repcz/Tool/raw/X/Clash/Rules/Netflix.list",
"path": "./rules/Netflix.list"
},
"Disney": {
...ruleProviderCommon,
"behavior": "classical",
"url": "https://github.com/Repcz/Tool/raw/X/Clash/Rules/Disney.list",
"path": "./rules/Disney.list"
},
"PrimeVideo": {
...ruleProviderCommon,
"behavior": "classical",
"url": "https://github.com/Repcz/Tool/raw/X/Clash/Rules/PrimeVideo.list",
"path": "./rules/PrimeVideo.list"
},
"HBO": {
...ruleProviderCommon,
"behavior": "classical",
"url": "https://github.com/Repcz/Tool/raw/X/Clash/Rules/HBO.list",
"path": "./rules/HBO.list"
},
"OneDrive": {
...ruleProviderCommon,
"behavior": "classical",
"url": "https://github.com/Repcz/Tool/raw/X/Clash/Rules/OneDrive.list",
"path": "./rules/OneDrive.list"
},
"Github": {
...ruleProviderCommon,
"behavior": "classical",
"url": "https://github.com/Repcz/Tool/raw/X/Clash/Rules/Github.list",
"path": "./rules/Github.list"
},
"Microsoft": {
...ruleProviderCommon,
"behavior": "classical",
"url": "https://github.com/Repcz/Tool/raw/X/Clash/Rules/Microsoft.list",
"path": "./rules/Microsoft.list"
},
"Lan": {
...ruleProviderCommon,
"behavior": "classical",
"url": "https://github.com/lism/Tool/raw/X/Clash/Rules/Lan.list",
"path": "./rules/Lan.list"
},
"ProxyGFW": {
...ruleProviderCommon,
"behavior": "classical",
"url": "https://github.com/Repcz/Tool/raw/X/Clash/Rules/ProxyGFW.list",
"path": "./rules/ProxyGFW.list"
}
};
// 覆盖规则
config["rules"] = [
"RULE-SET,AI,AI",
"RULE-SET,Apple,苹果服务",
"RULE-SET,YouTube,谷歌服务",
"RULE-SET,Google,谷歌服务",
"RULE-SET,Telegram,电报消息",
"RULE-SET,Twitter,推特消息",
"RULE-SET,Steam,游戏平台",
"RULE-SET,Epic,游戏平台",
"RULE-SET,Emby,Emby",
"RULE-SET,Spotify,国际媒体",
"RULE-SET,Bahamut,国际媒体",
"RULE-SET,Netflix,国际媒体",
"RULE-SET,Disney,国际媒体",
"RULE-SET,PrimeVideo,国际媒体",
"RULE-SET,HBO,国际媒体",
"GEOSITE,onedrive,微软服务",
"GEOSITE,github,微软服务",
"GEOSITE,microsoft,微软服务",
"GEOSITE,gfw,国外网站",
"GEOIP,lan,DIRECT",
"GEOIP,CN,DIRECT",
"MATCH,兜底分流"
];
// 返回修改后的配置
return config;
}