Skip to content

广告过滤规则订阅器,整合不同来源的规则,帮助你快速构建属于自己的规则集 | Ad Filter Rule Subscriber, integrating rules from various sources to help you quickly build your own rule set

License

Notifications You must be signed in to change notification settings

fordes123/ad-filters-subscriber

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AD Filter Subscriber

广告过滤规则订阅器,整合不同来源的规则,帮助你快速构建属于自己的规则集~

last update forks stars open issues license

English | 中文

📔 项目说明

本项目旨在聚合不同来源、不同格式的广告过滤规则,自由的进行转换和整合。

⚠️ 新版不再兼容原配置格式,迁移前务必注意

支持的规则格式

  • easylist
  • dnsmasq
  • clash
  • smartdns
  • hosts

注意事项

  1. 仅支持基本规则转换,即域名、通配域名构成的规则,对形如 ||example.org^$popup 等规则无法转换(合并、去重不受影响)
  2. 接受不可避免的缩限,如 ||example.org^ 将拦截 example.org 及其所有子域,但将其转换为 hosts 格式时,将无法匹配子域名。
  3. 规则有效性检测基于域名解析,因此仅支持基本规则 (只能检测当前域有效性,而无法检测其是否存在有效子域,故此功能可能存在误杀)。

🛠️ 快速开始

示例配置

application:
  
  # 输入配置
  input:
    - name: 'Subscription 1'               #可选参数: 规则名称,如无将使用 path 作为名称
      path: 'https://example.org/rule.txt' #必要参数: 规则 url (http/https) 或 本地文件位置 (绝对/相对路径)
      type: easylist                       #可选参数: 规则类型:easylist (默认)、dnsmasq、clash、smartdns、hosts

    - name: 'Subscription 2'
      path: 'rule/local.txt'
      type: hosts

  # 输出配置
  output:
    #文件头配置,将自动作为注释添加至每个规则文件开始
    #可使用占位符 ${name}、${type}、${desc} 以及 ${date} (当前日期)、${total} (规则总数)
    file_header: |
      ADFS AdBlock ${type}
      Last Modified: ${date}
      Total Size: ${total}
      Homepage: https://github.com/fordes123/ad-filters-subscriber/
      
    files:
      - name: easylist.txt     #必要参数: 文件名
        type: easylist         #必要参数: 文件类型: easylist、dnsmasq、clash、smartdns、hosts
        file_header:           #可选参数: 文件头配置,将自动作为注释添加至每个规则文件开始 (此处优先于 output.file_header)
        desc: 'ADFS EasyList'  #可选参数: 文件描述,可在file_header中通过 ${} 中使用
        filter:
          - basic              #基本规则,不包含任何控制、匹配符号, 可以转换为 hosts
          - wildcard           #通配规则,仅使用通配符
          - unknown            #其他规则,如使用了正则、高级修饰符号的规则,这些规则目前无法转换为其他格式
        rule:                  #可选参数: 限定此文件使用的规则源,如果不指定则使用 input 中的所有规则源
          - Subscription 1
          - Subscription 2     

本程序基于 Java21 编写,使用 Maven 进行构建,你可以参照示例配置,编辑 config/application.yaml ,并通过以下任意一种方式快速开始:

本地调试

git clone https://github.com/fordes123/ad-filters-subscriber.git
cd ad-filters-subscriber
mvn clean
mvn spring-boot:run

Github Action

  • fork 本项目
  • 自定义规则订阅 (可选)
    • 参照示例配置,修改配置文件: config/application.yaml
  • 打开 Github Action 页面,选中左侧 Update Filters 授权 Workflow 定时执行(⚠ 重要步骤)
  • 点击 Run workflow 或等待自动执行。执行完成后规则将生成在 release 分支

Codespaces

  • 登录 Github,点击本仓库右上角 Code 按钮,选择并创建新的 Codespaces
  • 等待 Codespaces 启动,即可直接对本项目进行调试

🎯 规则订阅

⚠ 本仓库不再提供规则订阅,我们更推荐 fork 本项目自行构建规则集.

下面是使用了本项目进行构建的规则仓库,可在其中寻找合适的规则订阅:

点击查看

💬 问题反馈

About

广告过滤规则订阅器,整合不同来源的规则,帮助你快速构建属于自己的规则集 | Ad Filter Rule Subscriber, integrating rules from various sources to help you quickly build your own rule set

Topics

Resources

License

Stars

Watchers

Forks