本项目旨在整合不同来源的广告过滤规则,通过 Github Action
定时执行,拉取远程规则,去重和分类输出。
根据过滤规则的特性,本项目将规则分为 DOMAIN
、REGEX
、MODIFY
、HOSTS
四种类型,它们之间互不包含, 你可在配置文件中自由的对四种类型进行组合:
DOMAIN
:基于域名的过滤规则,适用于几乎所有广告过滤工具REGEX
:包含通配符的域名过滤规则,适用于主流广告过滤工具MODIFY
:基于正则和其他修饰符的过滤规则,可以拦截页面上的特定元素,但不适用于DNS过滤HOSTS
:基于HOSTS
的过滤规则,适用于支持HOSTS
的所有设备
application:
rule:
#远程规则订阅,path为 http、https地址
remote:
- name: 'Subscription 1'
path: 'https://example.com/list.txt'
#本地规则,path为 操作系统支持的绝对或相对路径
local:
- name: 'private rule'
path: '/rule/private.txt'
output:
file_header: | #输出文件头, 占位符${name}将被替换为文件名, ${date} 将被替换为当前日期时间
[ADFS Adblock List]
! Title: ${name}
! Last Modified: ${date}
! Homepage: https://github.com/fordes123/ad-filters-subscriber/
path: rule #规则文件输出路径,相对路径默认为程序所在路径
files:
all.txt: #输出文件名, 下列表为其包含的规则类型
- DOMAIN #域名规则
- REGEX #正则规则
- MODIFY #修饰规则
- HOSTS #hosts规则
本程序基于 Java21
编写,使用 Maven
进行构建,你可以参照示例配置,编辑 src/main/resources/application.yml
,并通过以下任意一种方式快速开始:
git clone https://github.com/fordes123/ad-filters-subscriber.git
cd ad-filters-subscriber
mvn clean
mvn spring-boot:run
- fork 本项目
- 自定义规则订阅 (可选)
- 参照示例配置,修改配置文件:
src/main/resources/application.yml
- 参照示例配置,修改配置文件:
- 打开
Github Action
页面,选中左侧Update Filters
授权Workflow
定时执行(⚠ 重要步骤) - 点击
Run workflow
或等待自动执行。执行完成后相应规则生成在配置中指定的目录下
- 登录
Github
,点击本仓库右上角Code
按钮,选择并创建新的Codespaces
- 等待
Codespaces
启动,即可直接对本项目进行调试
此时选择 Sync fork 再选择 Update branch 即可同步更新.
(如曾修改过源代码,那么合并可能存在冲突,请谨慎处理)
⚠ 本仓库不再提供规则订阅,我们更推荐 fork 本项目自行构建规则集.
下面是使用了本项目进行构建的规则仓库,可在其中寻找合适的规则订阅:
点击查看
- xndeye/adblock_list
欢迎提交 issues 或 pr 留下你的仓库地址~
- 👉 issues