分享一个Clash Verge Rev 全局扩展脚本(懒人配置)/ Mihomo Party 覆写脚本

玩了好几个基于mihomo内核开发的代理工具,折腾了一个clash-verge-rev和mihomo-party的通用覆写脚本,并且支持合并多个机场订阅
直接将订阅链接填入url中就可以了,脚本也解决了dns泄露的问题。佬友们如果有其他规则想加,可以自己fork,也可以留言,我去添加一下。
github仓库地址:https://github.com/wanswu/my-backup
完整代码链接(可直连):Clash.js

我将 订阅合并 功能单独摘出来贴下面,包括JavaScript和yaml(任选其一)

实现订阅合并的JavaScript代码

// 多订阅合并,这里添加额外的地址
const proxyProviders = {
  "p1": {
    "type": "http",
    // 订阅 链接
    "url": "https://baidu.com",
    // 自动更新时间 86400(秒) / 3600 = 24小时
    "interval": 86400,
    "override": {
      // 节点名称前缀 p1,用于区别机场节点
      "additional-prefix": "p1 |"
    }
  },
  "p2": {
    "type": "http",
    "url": "https://google.com",
    "interval": 86400,
    "override": {
      "additional-prefix": "p2 |"
    }
  },
}
function main(config) {
  const proxyCount = config?.proxies?.length ?? 0;
  const originalProviders = config?.["proxy-providers"] || {};
  const proxyProviderCount = typeof originalProviders === "object" ? Object.keys(originalProviders).length : 0;

  if (proxyCount === 0 && proxyProviderCount === 0) {
    throw new Error("配置文件中未找到任何代理");
  }

  // 合并而非覆盖
  config["proxy-providers"] = {
    ...originalProviders,  // 保留原有配置
    ...proxyProviders       // 合并新配置(同名则覆盖)
  };
  return config;
}

实现订阅合并yaml

proxy-providers:
  subscribe1:
    type: http
    # 订阅 链接
    url: https://baidu.com
    # 自动更新时间 86400(秒) / 3600 = 24小时
    interval: 86400
    # 节点名称前缀 p1
    override:
      additional-prefix: "p1 |"
  subscribe2:
    type: http
    url: https://baidu.com
    interval: 86400
    override:
      additional-prefix: "P2 |"

Clash Verge Rev配置教程

Mihomo Party配置教程

在覆写中直接导入即可,Mihomo Party自带dns覆写需要关闭(在应用设置中关闭控制 DNS 设置

佬友可以通过下面的链接去测试

161 个赞

Welcome DNS Leak Test
clash verge rev2.2.2开始在dns覆写里面设置一下dns就不会有泄露了

11 个赞

谢谢大佬

8 个赞

脚本也适配了mihomo-party,所以就一块写了,防止clash verge哪个版本失效了,佬也可以用clash verge的dns覆写。

7 个赞

不客气,方便佬友们多个选择。

7 个赞

一定学一学
大佬能不能讲详细些?Clash.js是用来替换哪个文件还是在哪里新增一个文件?下面的代码好像跟Clash.js不是一回事?@wanswu

7 个赞

感谢大佬

6 个赞

重新更新了一下,你看一下

5 个赞

太棒了,正好需要

5 个赞


佬友,这样设置就可以实现订阅合并了吗?

5 个赞

clash-mihomo 一晚上上传好几百G正常吗

5 个赞

是的,你看你代理中的节点,有没有增加,增加就生效了

5 个赞

啊,这么离谱的

5 个赞

是的呀,我就是很好奇

5 个赞

不好意思,看错了,你如果只想合并你可以直接在全局扩展覆写配置(不是JavaScript)里面直接用官方的写,我的脚本是带分流规则的。
这是链接:多订阅合并 - Clash Verge Rev Docs

proxy-providers:
  1.provider1:
    type: http
    # 订阅 链接
    url: https://linux.do
    # 自动更新时间 86400(秒) / 3600 = 24小时
    interval: 86400
    # 节点名称前缀 p1
    override:
      additional-prefix: "p1 |"
  2.subscribe:
    type: https://linux.do
    url: 链接
    interval: 86400
    override:
      additional-prefix: "P2 |"
4 个赞

:joy:好,我说呢。节点每增加,还刷新了好几次。

5 个赞

查一下日志,具体是哪个应用

5 个赞

啊,撞头像了

5 个赞

哈哈哈,咱俩这审美别具一格

4 个赞

可以结合这个佬的

5 个赞