Skip to content

Commit

Permalink
Sat Feb 8 16:19:13 CST 2025
Browse files Browse the repository at this point in the history
  • Loading branch information
Sereinfy authored and github-actions[bot] committed Feb 8, 2025
1 parent 8243f3e commit 669cccb
Show file tree
Hide file tree
Showing 44 changed files with 358,997 additions and 14,273 deletions.
85 changes: 44 additions & 41 deletions README.md

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from .base import APPBase
from .adguard import AdGuard
from .adguardhome import AdGuardHome
from .clash import Clash
from .dnsmasq import DNSMasq
from .invizible import InviZible
from .mihomo import Mihomo
from .quantumultx import QuantumultX
from .shadowrocket import Shadowrocket
from .smartdns import SmartDNS
50 changes: 50 additions & 0 deletions app/mihomo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import os
from typing import List, Set, Dict

from loguru import logger

from app.base import APPBase

class Mihomo(APPBase):
def __init__(self, blockList:List[str], unblockList:List[str], filterDict:Dict[str,str], filterList:List[str], filterList_var:List[str], ChinaSet:Set[str], fileName:str, sourceRule:str):
super(Mihomo, self).__init__(blockList, unblockList, filterDict, filterList, filterList_var, ChinaSet, fileName, sourceRule)

def generate(self, isLite=False):
try:
if isLite:
logger.info("generate adblock Mihomo Lite...")
fileName = self.fileNameLite
blockList = self.blockListLite
else:
logger.info("generate adblock Mihomo...")
fileName = self.fileName
blockList = self.blockList

if os.path.exists(fileName):
os.remove(fileName)

# 生成规则文件
with open(fileName, 'a') as f:
f.write("payload:\n")
f.write(" #\n")
if isLite:
f.write(" # Title: AdBlock Clash Meta(Mihomo) Lite\n")
f.write(" # Description: 适用于 Clash Meta(Mihomo) 的去广告合并规则,每 8 个小时更新一次。规则源:%s。Lite 版仅针对国内域名拦截。\n"%(self.sourceRule))
else:
f.write(" # Title: AdBlock Clash Meta(Mihomo)\n")
f.write(" # Description: 适用于 Clash Meta(Mihomo) 的去广告合并规则,每 8 个小时更新一次。规则源:%s。\n"%(self.sourceRule))
f.write(" # Homepage: %s\n"%(self.homepage))
f.write(" # Source: %s/%s\n"%(self.source, os.path.basename(fileName)))
f.write(" # Version: %s\n"%(self.version))
f.write(" # Last modified: %s\n"%(self.time))
f.write(" # Blocked domains: %s\n"%(len(blockList)))
f.write(" #\n")
for domain in blockList:
f.write(" - '+.%s'\n"%(domain))

if isLite:
logger.info("adblock Mihomo Lite: block=%d"%(len(blockList)))
else:
logger.info("adblock Mihomo: block=%d"%(len(blockList)))
except Exception as e:
logger.error("%s"%(e))
20 changes: 10 additions & 10 deletions app/clash.py → app/shadowrocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@

from app.base import APPBase

class Clash(APPBase):
class Shadowrocket(APPBase):
def __init__(self, blockList:List[str], unblockList:List[str], filterDict:Dict[str,str], filterList:List[str], filterList_var:List[str], ChinaSet:Set[str], fileName:str, sourceRule:str):
super(Clash, self).__init__(blockList, unblockList, filterDict, filterList, filterList_var, ChinaSet, fileName, sourceRule)
super(Shadowrocket, self).__init__(blockList, unblockList, filterDict, filterList, filterList_var, ChinaSet, fileName, sourceRule)

def generate(self, isLite=False):
try:
if isLite:
logger.info("generate adblock Clash Lite...")
logger.info("generate adblock Shadowrocket Lite...")
fileName = self.fileNameLite
blockList = self.blockListLite
else:
logger.info("generate adblock Clash...")
logger.info("generate adblock Shadowrocket...")
fileName = self.fileName
blockList = self.blockList

Expand All @@ -27,11 +27,11 @@ def generate(self, isLite=False):
with open(fileName, 'a') as f:
f.write("#\n")
if isLite:
f.write("# Title: AdBlock Clash Lite\n")
f.write("# Description: 适用于 Clash 的去广告合并规则,每 8 个小时更新一次。规则源:%s。Lite 版仅针对国内域名拦截。\n"%(self.sourceRule))
f.write("# Title: AdBlock Shadowrocket Lite\n")
f.write("# Description: 适用于 Shadowrocket 的去广告合并规则,每 8 个小时更新一次。规则源:%s。Lite 版仅针对国内域名拦截。\n"%(self.sourceRule))
else:
f.write("# Title: AdBlock Clash\n")
f.write("# Description: 适用于 Clash 的去广告合并规则,每 8 个小时更新一次。规则源:%s。\n"%(self.sourceRule))
f.write("# Title: AdBlock Shadowrocket\n")
f.write("# Description: 适用于 Shadowrocket 的去广告合并规则,每 8 个小时更新一次。规则源:%s。\n"%(self.sourceRule))
f.write("# Homepage: %s\n"%(self.homepage))
f.write("# Source: %s/%s\n"%(self.source, os.path.basename(fileName)))
f.write("# Version: %s\n"%(self.version))
Expand All @@ -42,8 +42,8 @@ def generate(self, isLite=False):
f.write("DOMAIN-SUFFIX,%s\n"%(domain))

if isLite:
logger.info("adblock Clash Lite: block=%d"%(len(blockList)))
logger.info("adblock Shadowrocket Lite: block=%d"%(len(blockList)))
else:
logger.info("adblock Clash: block=%d"%(len(blockList)))
logger.info("adblock Shadowrocket: block=%d"%(len(blockList)))
except Exception as e:
logger.error("%s"%(e))
17 changes: 9 additions & 8 deletions filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from loguru import logger
from tld import get_tld

from app import APPBase, AdGuard, AdGuardHome, Clash, DNSMasq, InviZible, QuantumultX, SmartDNS
from app import APPBase, AdGuard, AdGuardHome, DNSMasq, InviZible, Mihomo, QuantumultX, Shadowrocket, SmartDNS
from readme import Rule
from resolver import Resolver

Expand Down Expand Up @@ -228,13 +228,14 @@ def generate(self, sourceRule):

# 生成合并规则 AdGuard, AdGuardHome, DNSMasq, InviZible, SmartDNS等
generaterList:List[APPBase] = [
AdGuard (blockList, unblockList, filterDict, filterList, filterList_var, ChinaSet, self.path + "/adblockfilters.txt", sourceRule),
AdGuardHome(blockList, unblockList, filterDict, filterList, filterList_var, ChinaSet, self.path + "/adblockdns.txt", sourceRule),
Clash (blockList, unblockList, filterDict, filterList, filterList_var, ChinaSet, self.path + "/adblockclash.list", sourceRule),
DNSMasq (blockList, unblockList, filterDict, filterList, filterList_var, ChinaSet, self.path + "/adblockdnsmasq.txt", sourceRule),
InviZible (blockList, unblockList, filterDict, filterList, filterList_var, ChinaSet, self.path + "/adblockdomain.txt", sourceRule),
QuantumultX(blockList, unblockList, filterDict, filterList, filterList_var, ChinaSet, self.path + "/adblockqx.conf", sourceRule),
SmartDNS (blockList, unblockList, filterDict, filterList, filterList_var, ChinaSet, self.path + "/adblocksmartdns.conf", sourceRule),
AdGuard (blockList, unblockList, filterDict, filterList, filterList_var, ChinaSet, self.path + "/adblockfilters.txt", sourceRule),
AdGuardHome (blockList, unblockList, filterDict, filterList, filterList_var, ChinaSet, self.path + "/adblockdns.txt", sourceRule),
DNSMasq (blockList, unblockList, filterDict, filterList, filterList_var, ChinaSet, self.path + "/adblockdnsmasq.txt", sourceRule),
InviZible (blockList, unblockList, filterDict, filterList, filterList_var, ChinaSet, self.path + "/adblockdomain.txt", sourceRule),
Mihomo (blockList, unblockList, filterDict, filterList, filterList_var, ChinaSet, self.path + "/adblockmihomo.yaml", sourceRule),
QuantumultX (blockList, unblockList, filterDict, filterList, filterList_var, ChinaSet, self.path + "/adblockqx.conf", sourceRule),
Shadowrocket(blockList, unblockList, filterDict, filterList, filterList_var, ChinaSet, self.path + "/adblockclash.list", sourceRule),
SmartDNS (blockList, unblockList, filterDict, filterList, filterList_var, ChinaSet, self.path + "/adblocksmartdns.conf", sourceRule),
]
for g in generaterList:
g.generateAll()
Expand Down
27 changes: 15 additions & 12 deletions readme.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self, filename:str):
"",
"https://gcore.jsdelivr.net/gh",
"https://github.boki.moe",
"https://mirror.ghproxy.com"
"https://ghfast.top"
]

def getRules(self) -> List[Rule]:
Expand Down Expand Up @@ -86,15 +86,16 @@ def regenerate(self):
f.write("\n")

f.write("## 订阅链接\n")
f.write("1. AdGuard Home 等 DNS 拦截服务使用规则1\n")
f.write("2. AdGuard 等浏览器插件使用规则1 + 规则2(规则2为规则1的补充,仅适用浏览器插件)\n")
f.write("3. InviZible Pro、personalDNSfilter 使用规则3(规则3与规则1拦截域名一致,仅格式差异)\n")
f.write("4. DNSMasq 使用规则4(与规则1拦截域名一致,仅格式差异)\n")
f.write("5. SmartDNS 使用规则5(与规则1拦截域名一致,仅格式差异)\n")
f.write("6. Clash 使用规则6(与规则1拦截域名一致,仅格式差异)\n")
f.write("7. QuantumultX 使用规则7(与规则1拦截域名一致,仅格式差异)\n")
f.write("8. 规则x’为规则x的 Lite 版,仅针对国内域名拦截,体积较小(如添加完整规则报错数量限制,请尝试 Lite 规则)\n")
f.write("9. 已对 jsdelivr 缓存进行主动刷新,但 jsdelivr 加速链接仍存在一定延时\n")
f.write("1. 规则x’为规则x的 Lite 版,仅针对国内域名拦截,体积较小(如添加完整规则报错数量限制,请尝试 Lite 规则)\n")
f.write("2. 已对 jsdelivr(加速链接1) 缓存进行主动刷新,但仍存在一定刷新延时\n")
f.write("3. AdGuard Home 等 DNS 拦截服务使用规则1\n")
f.write("4. AdGuard 等浏览器插件使用规则1 + 规则2(规则2为规则1的补充,仅适用浏览器插件)\n")
f.write("5. InviZible Pro、personalDNSfilter 使用规则3(规则3与规则1拦截域名一致,仅格式差异)\n")
f.write("6. DNSMasq 使用规则4(与规则1拦截域名一致,仅格式差异)\n")
f.write("7. SmartDNS 使用规则5(与规则1拦截域名一致,仅格式差异)\n")
f.write("8. Shadowrocket 使用规则6(与规则1拦截域名一致,仅格式差异)\n")
f.write("9. QuantumultX 使用规则7(与规则1拦截域名一致,仅格式差异)\n")
f.write("10. Clash Meta(Mihomo) 使用规则8(与规则1拦截域名一致,仅格式差异)\n")
f.write("\n")
tmp = "| 规则 | 原始链接 |"
for i in range(1, len(self.proxyList)):
Expand All @@ -113,10 +114,12 @@ def regenerate(self):
f.write("| 规则4' |" + self.__subscribeLink("adblockdnsmasqlite.txt") + " DNSMasq |\n")
f.write("| 规则5 |" + self.__subscribeLink("adblocksmartdns.conf") + " SmartDNS |\n")
f.write("| 规则5' |" + self.__subscribeLink("adblocksmartdnslite.conf") + " SmartDNS |\n")
f.write("| 规则6 |" + self.__subscribeLink("adblockclash.list") + " Clash |\n")
f.write("| 规则6' |" + self.__subscribeLink("adblockclashlite.list") + " Clash |\n")
f.write("| 规则6 |" + self.__subscribeLink("adblockclash.list") + " Shadowrocket |\n")
f.write("| 规则6' |" + self.__subscribeLink("adblockclashlite.list") + " Shadowrocket |\n")
f.write("| 规则7 |" + self.__subscribeLink("adblockqx.conf") + " QuantumultX |\n")
f.write("| 规则7' |" + self.__subscribeLink("adblockqxlite.conf") + " QuantumultX |\n")
f.write("| 规则8 |" + self.__subscribeLink("adblockmihomo.yaml") + " Clash Meta(Mihomo) |\n")
f.write("| 规则8' |" + self.__subscribeLink("adblockmihomolite.yaml") + " Clash Meta(Mihomo) |\n")
f.write("\n")

f.write("## 上游规则源\n")
Expand Down
1 change: 1 addition & 0 deletions readme/line.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
285309
285244
283871
286279
Expand Down
2 changes: 0 additions & 2 deletions rules/AdGuard_Annoyances_filter.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54999,8 +54999,6 @@ file-mods.ru#%#//scriptlet('adjust-setInterval', 'timer', '1000', '0.001')
! https://github.com/AdguardTeam/AdguardFilters/issues/174126
bfmtv.com#%#//scriptlet('remove-attr', 'autoplay', '.video_block')
bfmtv.com#%#//scriptlet('set-attr', '.video_block', 'autoplay', 'false')
! https://github.com/AdguardTeam/AdguardFilters/issues/122322
kuncomic.com#%#//scriptlet('adjust-setInterval', 'countdownTime', '1500', '0.001')
! gplinks - gplinks.co/fi3p
! https://github.com/AdguardTeam/AdguardFilters/issues/170980
sololevelinghindi.pro#%#//scriptlet('adjust-setInterval', 'myTimer', '*', '0.02')
Expand Down
Loading

0 comments on commit 669cccb

Please sign in to comment.