-
Notifications
You must be signed in to change notification settings - Fork 1
/
sing-box-origin.js
81 lines (74 loc) · 2.26 KB
/
sing-box-origin.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
const {
type,
name
} = $arguments
const compatible_outbound = {
tag: 'COMPATIBLE',
type: '🍬 direct',
}
let compatible
let config = JSON.parse($files[0])
let proxies = await produceArtifact({
name,
type: /^1$|col/i.test(type) ? 'collection' : 'subscription',
platform: 'sing-box',
produceType: 'internal',
})
config.outbounds.push(...proxies)
config.outbounds.map(i => {
if (['🧬 auto'].includes(i.tag)) {
i.outbounds.push(...getTags(proxies))
}
if (['❀ YouTube'].includes(i.tag)) {
i.outbounds.push(...["🇸🇬 Singapore", "🇯🇵 Japan"])
}
if (['🇦🇺 Australia'].includes(i.tag)) {
i.outbounds.push(...getTags(proxies, /Australia/i))
}
if (['🇨🇦 Canada'].includes(i.tag)) {
i.outbounds.push(...getTags(proxies, /Canada/i))
}
if (['🇫🇷 France'].includes(i.tag)) {
i.outbounds.push(...getTags(proxies, /France/i))
}
if (['🇩🇪 Germany'].includes(i.tag)) {
i.outbounds.push(...getTags(proxies, /Germany/i))
}
if (['🇭🇰 Hong Kong'].includes(i.tag)) {
i.outbounds.push(...getTags(proxies, /Hong Kong/i))
}
if (['🇨🇳 Taiwan'].includes(i.tag)) {
i.outbounds.push(...getTags(proxies, /Taiwan/i))
}
if (['🇯🇵 Japan'].includes(i.tag)) {
i.outbounds.push(...getTags(proxies, /Japan/i))
}
if (['🇷🇺 Russia'].includes(i.tag)) {
i.outbounds.push(...getTags(proxies, /Russia/i))
}
if (['🇸🇬 Singapore'].includes(i.tag)) {
i.outbounds.push(...getTags(proxies, /Singapore/i))
}
if (['🇰🇷 Korea'].includes(i.tag)) {
i.outbounds.push(...getTags(proxies, /Korea/i))
}
if (['🇬🇧 United Kingdom'].includes(i.tag)) {
i.outbounds.push(...getTags(proxies, /United Kingdom/i))
}
if (['🇺🇸 United States'].includes(i.tag)) {
i.outbounds.push(...getTags(proxies, /United States/i))
}
})
config.outbounds.forEach(outbound => {
if (Array.isArray(outbound.outbounds) && outbound.outbounds.length === 0) {
if (!compatible) {
config.outbounds.push(compatible_outbound)
compatible = true
}
outbound.outbounds.push(compatible_outbound.tag);
}
});
$content = JSON.stringify(config, null, 2)
function getTags(proxies, regex) {
return (regex ? proxies.filter(p => regex.test(p.tag)) : proxies).map(p => p.tag)
}