-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
784 lines (716 loc) · 25.8 KB
/
Copy pathindex.js
File metadata and controls
784 lines (716 loc) · 25.8 KB
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
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
/***
* Clash Verge Rev 全局扩展脚本(懒人配置)/ Mihomo Party 覆写脚本
* 基于: https://github.com/dahaha-365/YaNet/
* URL:https://github.com/FantasyMiku/RulesGroup
*/
/**
* 整个脚本的总开关,在Mihomo Party使用的话,请保持为true
* true = 启用
* false = 禁用
*/
const enable = true
/**
* 分流规则配置,会自动生成对应的策略组
* 设置的时候可遵循“最小,可用”原则,把自己不需要的规则全禁用掉,提高效率
* true = 启用
* false = 禁用
*/
const ruleOptions = {
apple: true, // 苹果服务
microsoft: true, // 微软服务
github: true, // Github
google: true, // Google服务
openai: true, // 国外AI和GPT
spotify: false, // Spotify
youtube: false, // YouTube
bahamut: false, // 巴哈姆特/动画疯
netflix: false, // Netflix网飞
tiktok: false, // 国际版抖音
disney: false, // 迪士尼
pixiv: true, // Pixiv
hbo: false, // HBO
biliintl: false, // 哔哩哔哩东南亚
tvb: false, // TVB
hulu: false, // Hulu
primevideo: false, // 亚马逊prime video
telegram: true, // Telegram通讯软件
line: true, // Line通讯软件
whatsapp: true, // Whatsapp
games: true, // 游戏策略组
japan: false, // 日本网站策略组
tracker: true, // 网络分析和跟踪服务
ads: true, // 常见的网络广告
}
/**
* 这是一个前置规则自定义
* 默认是带了向日葵和AnyDesk
*/
const rules = [
'RULE-SET,applications,下载软件',
'PROCESS-NAME,SunloginClient,DIRECT',
'PROCESS-NAME,SunloginClient.exe,DIRECT',
'PROCESS-NAME,AnyDesk,DIRECT',
'PROCESS-NAME,AnyDesk.exe,DIRECT',
'DOMAIN-SUFFIX,eslint.org.cn,其他外网',
]
/**
* 地区配置,通过regex匹配代理节点名称
* regex会有一定概率误判,自己调整一下吧
* excludeHighPercentage是排除高倍率节点的开关,只对地区分组有效
* 倍率大于regions里的ratioLimit值的代理节点会被排除
*/
const regionOptions = {
excludeHighPercentage: true,
regions: [
{
name: 'HK香港',
regex: /港|🇭🇰|HK|hongkong|hong kong/i,
ratioLimit: 2,
icon: 'https://fastly.jsdelivr.net/gh/Koolson/Qure/IconSet/Color/Hong_Kong.png',
},
{
name: 'US美国',
regex: /美|🇺🇸|US|united state|america/i,
ratioLimit: 2,
icon: 'https://fastly.jsdelivr.net/gh/Koolson/Qure/IconSet/Color/United_States.png',
},
{
name: 'JP日本',
regex: /日本|🇯🇵|JP|japan/i,
ratioLimit: 2,
icon: 'https://fastly.jsdelivr.net/gh/Koolson/Qure/IconSet/Color/Japan.png',
},
{
name: 'KR韩国',
regex: /韩|🇰🇷|KR|korea/i,
ratioLimit: 2,
icon: 'https://fastly.jsdelivr.net/gh/Koolson/Qure/IconSet/Color/Korea.png',
},
{
name: 'SG新加坡',
regex: /新加坡|🇸🇬|SG|singapore/i,
ratioLimit: 2,
icon: 'https://fastly.jsdelivr.net/gh/Koolson/Qure/IconSet/Color/Singapore.png',
},
{
name: 'CN中国大陆',
regex: /中国|🇨🇳|CN|china/i,
ratioLimit: 2,
icon: 'https://fastly.jsdelivr.net/gh/Koolson/Qure/IconSet/Color/China_Map.png',
},
{
name: 'TW台湾省',
regex: /台湾|🇹🇼|TW|taiwan|tai wan/i,
ratioLimit: 2,
icon: 'https://fastly.jsdelivr.net/gh/Koolson/Qure/IconSet/Color/China.png',
},
{
name: 'GB英国',
regex: /英|🇬🇧|UK|united kingdom|great britain/i,
ratioLimit: 2,
icon: 'https://fastly.jsdelivr.net/gh/Koolson/Qure/IconSet/Color/United_Kingdom.png',
},
{
name: 'DE德国',
regex: /德国|🇩🇪|DE|germany/i,
ratioLimit: 2,
icon: 'https://fastly.jsdelivr.net/gh/Koolson/Qure/IconSet/Color/Germany.png',
},
{
name: 'MY马来西亚',
regex: /马来|🇩🇪|MY|malaysia/i,
ratioLimit: 2,
icon: 'https://fastly.jsdelivr.net/gh/Koolson/Qure/IconSet/Color/Malaysia.png',
},
{
name: 'TK土耳其',
regex: /土耳其|🇹🇷|TK|turkey/i,
ratioLimit: 2,
icon: 'https://fastly.jsdelivr.net/gh/Koolson/Qure/IconSet/Color/Turkey.png',
},
],
}
/**
* 国内两组DNS作为主解析(防止代理失效的时候全局断网)
* 国外DNS作为对外解析(防止国内DNS被污染)
*/
const chinaDNS = [
'https://223.5.5.5/dns-query#h3=true',
'https://223.6.6.6/dns-query#h3=true',
'https://doh.pub/dns-query',
'https://1.12.12.12/dns-query',
]
const foreignDNS = [
'https://185.236.104.104/dns-query#PROXY#h3=true',
'https://1.1.1.1/dns-query#PROXY#h3=true',
'https://1.0.0.1/dns-query#PROXY#h3=true',
'https://8.8.8.8/dns-query#PROXY#h3=true',
'quic://Sakura-a27685.dns.nextdns.io',
]
/**
* 腾讯DNS,专门给QQ做解析用的(毕竟自己解析自己速度最快x)
*/
const qqDNS = ['https://doh.pub/dns-query', '119.29.29.29']
/**
* DNS相关配置
*/
const dnsConfig = {
enable: true,
listen: ':1053',
ipv6: false,
'prefer-h3': true,
'use-hosts': true,
'use-system-hosts': true,
'respect-rules': true,
'enhanced-mode': 'fake-ip',
'fake-ip-range': '198.18.0.1/16',
'fake-ip-filter': ['*', '+.lan', '+.local', '+.market.xiaomi.com'],
nameserver: [...chinaDNS],
'proxy-server-nameserver': [...chinaDNS],
/**
* 这里对域名解析进行分流
* 默认DNS为国内,根据GEO数据自动分流
*/
'nameserver-policy': {
'geosite:private': 'system',
'+.qq.com,+.tencents.com': qqDNS,
'geosite:cn,steam@cn,category-games@cn,microsoft@cn,apple@cn': chinaDNS,
'geosite:geolocation-!cn': foreignDNS,
},
}
// 规则集通用配置
const ruleProviderCommon = {
type: 'http',
format: 'yaml',
interval: 86400,
}
// 代理组通用配置
const groupBaseOption = {
interval: 300,
timeout: 5000,
url: 'http://cp.cloudflare.com/generate_204',
lazy: true,
'max-failed-times': 3,
hidden: false,
}
const ruleProviders = new Map()
ruleProviders.set('applications', {
...ruleProviderCommon,
behavior: 'classical',
format: 'text',
url: 'https://fastly.jsdelivr.net/gh/DustinWin/ruleset_geodata@clash-ruleset/applications.list',
path: './ruleset/DustinWin/applications.list',
})
// 程序入口
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('配置文件中未找到任何代理')
}
let regionProxyGroups = []
let otherProxyGroups = config.proxies.map((b) => {
return b.name
})
let fallbackGroups = config.proxies.filter((value) => {
const name = value.name === null ? undefined : value.name
return name.includes('香港') && (name.includes('Hy2') || name.includes('Worker'))
}).map((b) => {
return b.name
});
config['allow-lan'] = true
config['bind-address'] = '*'
config['mode'] = 'rule'
// 覆盖原配置中DNS配置
config['dns'] = dnsConfig
config['profile'] = {
'store-selected': true,
'store-fake-ip': true,
}
config['unified-delay'] = true
config['tcp-concurrent'] = true
/**
* 这个值设置大点能省电,笔记本和手机需要关注一下
*/
config['keep-alive-interval'] = 1800
config['find-process-mode'] = 'strict'
config['geodata-mode'] = true
/**
* 适合小内存环境,如果在旁路由里运行可以改成standard
*/
config['geodata-loader'] = 'memconservative'
config['geox-url'] = {
geosite: "https://cdn.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@release/geosite.dat",
geoip: "https://cdn.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@release/geoip.dat",
mmdb: "https://cdn.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@release/country.mmdb"
}
config['geo-auto-update'] = true
config['geo-update-interval'] = 24
/**
* 不开域名嗅探的话,日志里只会记录请求的ip,对查找问题不方便
* override-destination默认值是true,但是个人建议全局设为false,否则某些应用会出现莫名其妙的问题
* Mijia Cloud跳过是网上抄的
*/
config['sniffer'] = {
enable: true,
'force-dns-mapping': true,
'parse-pure-ip': false,
'override-destination': true,
sniff: {
TLS: {
ports: [443, 8443],
},
HTTP: {
ports: [80, '8080-8880'],
},
QUIC: {
ports: [443, 8443],
},
},
'skip-src-address': [
'127.0.0.0/8',
'192.168.0.0/16',
'10.0.0.0/8',
'172.16.0.0/12',
],
'force-domain': [
'+.google.com',
'+.googleapis.com',
'+.googleusercontent.com',
'+.youtube.com',
'+.facebook.com',
'+.messenger.com',
'+.fbcdn.net',
'fbcdn-a.akamaihd.net',
],
'skip-domain': ['Mijia Cloud', '+.oray.com'],
}
/**
* write-to-system如果设为true的话,有可能出现电脑时间不对的问题
*/
config['ntp'] = {
enable: true,
'write-to-system': false,
server: 'cn.ntp.org.cn',
}
config['geox-url'] = {
geoip:
'https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geoip-lite.dat',
geosite:
'https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geosite.dat',
mmdb: 'https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/country-lite.mmdb',
asn: 'https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/GeoLite2-ASN.mmdb',
}
/**
* 总开关关闭时不处理策略组
*/
if (!enable) {
return config
}
regionOptions.regions.forEach((region) => {
/**
* 提取倍率符合要求的代理节点
* 判断倍率有问题的话,大概率是这个正则的问题,可以自行修改
* 自己改正则的话记得必须把倍率的number值提取出来
*/
let proxies = config.proxies
.filter((a) => {
const multiplier =
/(?<=[xX✕✖⨉倍率])([1-9]+(\.\d+)*|0{1}\.\d+)(?=[xX✕✖⨉倍率])*/i.exec(
a.name
)?.[1]
return (
a.name.match(region.regex) &&
parseFloat(multiplier || '0') <= region.ratioLimit
)
})
.map((b) => {
return b.name
})
/**
* 必须再判断一下有没有符合要求的代理节点
* 没有的话,这个策略组就不应该存在
* 我喜欢自动选择延迟最低的节点,喜欢轮询的可以自己修改
*/
if (proxies.length > 0) {
regionProxyGroups.push({
...groupBaseOption,
name: region.name,
type: 'select',
tolerance: 50,
icon: region.icon,
proxies: proxies,
})
}
otherProxyGroups = otherProxyGroups.filter((x) => !proxies.includes(x))
})
const proxyGroupsRegionNames = regionProxyGroups.map((value) => {
return value.name
})
if (otherProxyGroups.length > 0) {
proxyGroupsRegionNames.push('其他节点')
}
config['proxy-groups'] = [
{
...groupBaseOption,
name: '默认节点',
type: 'select',
proxies: [...proxyGroupsRegionNames, '自动回退', '直连'],
icon: 'https://fastly.jsdelivr.net/gh/Koolson/Qure/IconSet/Color/Proxy.png',
},
{
...groupBaseOption,
name: '自动回退',
type: 'fallback',
proxies: fallbackGroups,
icon: 'https://fastly.jsdelivr.net/gh/Koolson/Qure/IconSet/Color/Auto.png',
}
]
config.proxies = config?.proxies || []
config.proxies.push({
name: '直连',
type: 'direct',
udp: true,
})
if (ruleOptions.openai) {
rules.push(
'DOMAIN-SUFFIX,chatgpt.com,国外AI',
'DOMAIN-SUFFIX,grazie.ai,国外AI',
'DOMAIN-SUFFIX,grazie.aws.intellij.net,国外AI',
'RULE-SET,ai,国外AI',
)
ruleProviders.set('ai', {
...ruleProviderCommon,
behavior: 'classical',
format: 'text',
url: 'https://github.com/dahaha-365/YaNet/raw/refs/heads/dist/rulesets/mihomo/ai.list',
path: './ruleset/YaNet/ai.list',
})
config['proxy-groups'].push({
...groupBaseOption,
name: '国外AI',
type: 'select',
proxies: ['默认节点', ...proxyGroupsRegionNames, '直连'],
url: 'https://chat.openai.com/cdn-cgi/trace',
icon: 'https://fastly.jsdelivr.net/gh/Koolson/Qure/IconSet/Color/ChatGPT.png',
})
}
if (ruleOptions.youtube) {
rules.push('GEOSITE,youtube,YouTube')
config['proxy-groups'].push({
...groupBaseOption,
name: 'YouTube',
type: 'select',
proxies: ['默认节点', ...proxyGroupsRegionNames, '直连'],
url: 'https://www.youtube.com/s/desktop/494dd881/img/favicon.ico',
icon: 'https://fastly.jsdelivr.net/gh/Koolson/Qure/IconSet/Color/YouTube.png',
})
}
if (ruleOptions.biliintl) {
rules.push('GEOSITE,biliintl,哔哩哔哩东南亚')
config['proxy-groups'].push({
...groupBaseOption,
name: '哔哩哔哩东南亚',
type: 'select',
proxies: ['默认节点', '直连', ...proxyGroupsRegionNames],
url: 'https://www.bilibili.tv/',
icon: 'https://fastly.jsdelivr.net/gh/Koolson/Qure/IconSet/Color/bilibili_3.png',
})
}
if (ruleOptions.bahamut) {
rules.push('GEOSITE,bahamut,巴哈姆特')
config['proxy-groups'].push({
...groupBaseOption,
name: '巴哈姆特',
type: 'select',
proxies: ['默认节点', '直连', ...proxyGroupsRegionNames],
url: 'https://ani.gamer.com.tw/ajax/getdeviceid.php',
icon: 'https://fastly.jsdelivr.net/gh/Koolson/Qure/IconSet/Color/Bahamut.png',
})
}
if (ruleOptions.disney) {
rules.push('GEOSITE,disney,Disney+')
config['proxy-groups'].push({
...groupBaseOption,
name: 'Disney+',
type: 'select',
proxies: ['默认节点', ...proxyGroupsRegionNames, '直连'],
url: 'https://disney.api.edge.bamgrid.com/devices',
icon: 'https://fastly.jsdelivr.net/gh/Koolson/Qure/IconSet/Color/Disney+.png',
})
}
if (ruleOptions.netflix) {
rules.push('GEOSITE,netflix,NETFLIX')
config['proxy-groups'].push({
...groupBaseOption,
name: 'NETFLIX',
type: 'select',
proxies: ['默认节点', ...proxyGroupsRegionNames, '直连'],
url: 'https://api.fast.com/netflix/speedtest/v2?https=true',
icon: 'https://fastly.jsdelivr.net/gh/Koolson/Qure/IconSet/Color/Netflix.png',
})
}
if (ruleOptions.tiktok) {
rules.push('GEOSITE,tiktok,Tiktok')
config['proxy-groups'].push({
...groupBaseOption,
name: 'Tiktok',
type: 'select',
proxies: ['默认节点', ...proxyGroupsRegionNames, '直连'],
url: 'https://www.tiktok.com/',
icon: 'https://fastly.jsdelivr.net/gh/Koolson/Qure/IconSet/Color/TikTok.png',
})
}
if (ruleOptions.spotify) {
rules.push('GEOSITE,spotify,Spotify')
config['proxy-groups'].push({
...groupBaseOption,
name: 'Spotify',
type: 'select',
proxies: ['默认节点', ...proxyGroupsRegionNames, '直连'],
url: 'http://spclient.wg.spotify.com/signup/public/v1/account',
icon: 'https://fastly.jsdelivr.net/gh/Koolson/Qure/IconSet/Color/Spotify.png',
})
}
if (ruleOptions.pixiv) {
rules.push('GEOSITE,pixiv,Pixiv')
config['proxy-groups'].push({
...groupBaseOption,
name: 'Pixiv',
type: 'select',
proxies: ['默认节点', ...proxyGroupsRegionNames, '直连'],
url: 'http://spclient.wg.spotify.com/signup/public/v1/account',
icon: 'https://play-lh.googleusercontent.com/8pFuLOHF62ADcN0ISUAyEueA5G8IF49mX_6Az6pQNtokNVHxIVbS1L2NM62H-k02rLM=w240-h480-rw',
})
}
if (ruleOptions.hbo) {
rules.push('GEOSITE,hbo,HBO')
config['proxy-groups'].push({
...groupBaseOption,
name: 'HBO',
type: 'select',
proxies: ['默认节点', ...proxyGroupsRegionNames, '直连'],
url: 'https://www.hbo.com/favicon.ico',
icon: 'https://fastly.jsdelivr.net/gh/Koolson/Qure/IconSet/Color/HBO.png',
})
}
if (ruleOptions.tvb) {
rules.push('GEOSITE,tvb,TVB')
config['proxy-groups'].push({
...groupBaseOption,
name: 'TVB',
type: 'select',
proxies: ['默认节点', ...proxyGroupsRegionNames, '直连'],
url: 'https://www.tvb.com/logo_b.svg',
icon: 'https://fastly.jsdelivr.net/gh/Koolson/Qure/IconSet/Color/TVB.png',
})
}
if (ruleOptions.primevideo) {
rules.push('GEOSITE,primevideo,Prime Video')
config['proxy-groups'].push({
...groupBaseOption,
name: 'Prime Video',
type: 'select',
proxies: ['默认节点', ...proxyGroupsRegionNames, '直连'],
url: 'https://m.media-amazon.com/images/G/01/digital/video/web/logo-min-remaster.png',
icon: 'https://fastly.jsdelivr.net/gh/Koolson/Qure/IconSet/Color/Prime_Video.png',
})
}
if (ruleOptions.hulu) {
rules.push('GEOSITE,hulu,Hulu')
config['proxy-groups'].push({
...groupBaseOption,
name: 'Hulu',
type: 'select',
proxies: ['默认节点', ...proxyGroupsRegionNames, '直连'],
url: 'https://auth.hulu.com/v4/web/password/authenticate',
icon: 'https://fastly.jsdelivr.net/gh/Koolson/Qure/IconSet/Color/Hulu.png',
})
}
if (ruleOptions.telegram) {
rules.push('GEOIP,telegram,Telegram')
config['proxy-groups'].push({
...groupBaseOption,
name: 'Telegram',
type: 'select',
proxies: ['默认节点', ...proxyGroupsRegionNames, '直连'],
url: 'http://www.telegram.org/img/website_icon.svg',
icon: 'https://fastly.jsdelivr.net/gh/Koolson/Qure/IconSet/Color/Telegram.png',
})
}
if (ruleOptions.whatsapp) {
rules.push('GEOSITE,whatsapp,WhatsApp')
config['proxy-groups'].push({
...groupBaseOption,
name: 'WhatsApp',
type: 'select',
proxies: ['默认节点', ...proxyGroupsRegionNames, '直连'],
url: 'https://web.whatsapp.com/data/manifest.json',
icon: 'https://static.whatsapp.net/rsrc.php/v3/yP/r/rYZqPCBaG70.png',
})
}
if (ruleOptions.line) {
rules.push('GEOSITE,line,Line')
config['proxy-groups'].push({
...groupBaseOption,
name: 'Line',
type: 'select',
proxies: ['默认节点', ...proxyGroupsRegionNames, '直连'],
url: 'https://line.me/page-data/app-data.json',
icon: 'https://fastly.jsdelivr.net/gh/Koolson/Qure/IconSet/Color/Line.png',
})
}
if (ruleOptions.games) {
rules.push(
'GEOSITE,category-games@cn,国内网站',
'GEOSITE,category-games,游戏专用'
)
config['proxy-groups'].push({
...groupBaseOption,
name: '游戏专用',
type: 'select',
proxies: ['默认节点', ...proxyGroupsRegionNames, '直连'],
icon: 'https://fastly.jsdelivr.net/gh/Koolson/Qure/IconSet/Color/Game.png',
})
}
if (ruleOptions.tracker) {
rules.push('GEOSITE,tracker,跟踪分析')
config['proxy-groups'].push({
...groupBaseOption,
name: '跟踪分析',
type: 'select',
proxies: ['REJECT', '直连', '默认节点'],
icon: 'https://fastly.jsdelivr.net/gh/Koolson/Qure/IconSet/Color/Reject.png',
})
}
if (ruleOptions.ads) {
rules.push('GEOSITE,category-ads-all,广告过滤')
config['proxy-groups'].push({
...groupBaseOption,
name: '广告过滤',
type: 'select',
proxies: ['REJECT', '直连', '默认节点'],
icon: 'https://fastly.jsdelivr.net/gh/Koolson/Qure/IconSet/Color/Advertising.png',
})
}
if (ruleOptions.apple) {
rules.push('GEOSITE,apple-cn,苹果服务')
config['proxy-groups'].push({
...groupBaseOption,
name: '苹果服务',
type: 'select',
proxies: ['默认节点', ...proxyGroupsRegionNames, '直连'],
url: 'http://www.apple.com/library/test/success.html',
icon: 'https://fastly.jsdelivr.net/gh/Koolson/Qure/IconSet/Color/Apple_2.png',
})
}
if (ruleOptions.google) {
rules.push('GEOSITE,google,谷歌服务')
config['proxy-groups'].push({
...groupBaseOption,
name: '谷歌服务',
type: 'select',
proxies: ['默认节点', ...proxyGroupsRegionNames, '直连'],
url: 'http://www.google.com/generate_204',
icon: 'https://fastly.jsdelivr.net/gh/Koolson/Qure/IconSet/Color/Google_Search.png',
})
}
if (ruleOptions.github) {
rules.push('GEOSITE,github,Github')
config['proxy-groups'].push({
...groupBaseOption,
name: 'Github',
type: 'select',
proxies: ['默认节点', ...proxyGroupsRegionNames, '直连'],
url: 'https://github.com/robots.txt',
icon: 'https://fastly.jsdelivr.net/gh/Koolson/Qure/IconSet/Color/GitHub.png',
})
}
if (ruleOptions.microsoft) {
rules.push('GEOSITE,microsoft@cn,国内网站', 'GEOSITE,microsoft,微软服务')
config['proxy-groups'].push({
...groupBaseOption,
name: '微软服务',
type: 'select',
proxies: ['默认节点', ...proxyGroupsRegionNames, '直连'],
url: 'http://www.msftconnecttest.com/connecttest.txt',
icon: 'https://fastly.jsdelivr.net/gh/Koolson/Qure/IconSet/Color/Microsoft.png',
})
}
if (ruleOptions.japan) {
rules.push(
'RULE-SET,category-bank-jp,日本网站',
'GEOIP,jp,日本网站,no-resolve'
)
ruleProviders.set('category-bank-jp', {
...ruleProviderCommon,
behavior: 'domain',
format: 'mrs',
url: 'https://fastly.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@meta/geo/geosite/category-bank-jp.mrs',
path: './ruleset/MetaCubeX/category-bank-jp.mrs',
})
config['proxy-groups'].push({
...groupBaseOption,
name: '日本网站',
type: 'select',
proxies: ['默认节点', ...proxyGroupsRegionNames, '直连'],
url: 'https://r.r10s.jp/com/img/home/logo/touch.png',
icon: 'https://fastly.jsdelivr.net/gh/Koolson/Qure/IconSet/Color/JP.png',
})
}
rules.push(
'GEOSITE,private,DIRECT',
'GEOIP,private,DIRECT,no-resolve',
'GEOSITE,cn,国内网站',
'GEOIP,cn,国内网站,no-resolve',
'MATCH,其他外网'
)
config['proxy-groups'].push(
{
...groupBaseOption,
name: '下载软件',
type: 'select',
proxies: [
'直连',
'REJECT',
'默认节点',
'国内网站',
...proxyGroupsRegionNames,
],
icon: 'https://fastly.jsdelivr.net/gh/Koolson/Qure/IconSet/Color/Download.png',
},
{
...groupBaseOption,
name: '其他外网',
type: 'select',
proxies: ['默认节点', '国内网站', ...proxyGroupsRegionNames],
icon: 'https://fastly.jsdelivr.net/gh/Koolson/Qure/IconSet/Color/Streaming!CN.png',
},
{
...groupBaseOption,
name: '国内网站',
type: 'select',
proxies: ['直连', '默认节点', ...proxyGroupsRegionNames],
url: 'http://wifi.vivo.com.cn/generate_204',
icon: 'https://fastly.jsdelivr.net/gh/Koolson/Qure/IconSet/Color/StreamingCN.png',
}
)
config['proxy-groups'] = config['proxy-groups'].concat(regionProxyGroups)
// 覆盖原配置中的规则
config['rules'] = rules
config['rule-providers'] = Object.fromEntries(ruleProviders)
if (otherProxyGroups.length > 0) {
config['proxy-groups'].push({
...groupBaseOption,
name: '其他节点',
type: 'select',
proxies: otherProxyGroups,
icon: 'https://fastly.jsdelivr.net/gh/Koolson/Qure/IconSet/Color/World_Map.png',
})
}
// 返回修改后的配置
return config
}