1. 假设你有一个配置模板, 可以是本地文本也可以是远程配置
如图1, 其中 HKG 里是自建落地节点, HKG-R 里是机场节点.
你希望使用 机场节点 拉 落地节点
2. 加上两条脚本操作, 如图 2(具体参数含义可查看脚本文件头部的描述, 也可以查看
https://raw.githubusercontent.com/xream/scripts/main/surge/modules/sub-store-scripts/sing-box/template.js#type=组合订阅&name=自建&outbound=🕳ℹ️^🇭🇰 HKG$🏷ℹ️港|hk|hongkong|kong kong|🇭🇰
https://raw.githubusercontent.com/xream/scripts/main/surge/modules/sub-store-scripts/sing-box/template.js#type=组合订阅&name=机场&outbound=🕳ℹ️^🇭🇰 HKG-R$🏷ℹ️港|hk|hongkong|kong kong|🇭🇰
此时可以预览, 应该能看到节点都加上了
3. 添加一个脚本操作, 如图3. 此脚本的作用是给 HKG 里的每一个节点, 加上
detour: HKG-R. 没优化, 反正能用(config = JSON.parse($content ?? $files[0])
const relay = {
'🇭🇰 HKG': '🇭🇰 HKG-R',
// 其他的自己加
}
config.outbounds.map(outbound => {
const r = relay[outbound.tag]
if(r && Array.isArray(outbound.outbounds) && outbound.outbounds.length > 0){
outbound.outbounds.map(tag => {
config.outbounds.find(outbound => outbound.tag === tag).detour = r
})
}
})
$content = JSON.stringify(config, null, 2)
- 👍9
- ❤️5
- 🎉1