Skip to content

Commit

Permalink
Fix adblock
Browse files Browse the repository at this point in the history
  • Loading branch information
peasoft committed Jul 2, 2023
1 parent c5bed88 commit ceac2e2
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 60 deletions.
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

## 公告

### 注意:原有的链接 1 似乎已经挂掉了,我们修改了这个链接。我们建议您将订阅链接改为新的加速链接 1。加速链接 2/3 含有缓存,可能不是最新,且访问速度没有链接 1 快。
### 注意:原有的链接 1 出现过问题,我们在它前面添加了新的链接 1 并下移了原有链接。我们建议您将订阅链接改为新的加速链接 1。加速链接 3/4 含有缓存,可能不是最新,且访问速度没有链接 1 快。

此项目现已添加“反 996 许可证”,请各位使用者**不要违法违规要求别人加班,自觉遵守《中华人民共和国劳动法》及其它法律法规**

Expand All @@ -15,16 +15,18 @@
添加 Base64 订阅:
- [原始链接](https://raw.githubusercontent.com/peasoft/NoMoreWalls/master/list.txt)
- [加速链接 1](https://ghproxy.com/https://raw.githubusercontent.com/peasoft/NoMoreWalls/master/list.txt)
- [加速链接 2](https://fastly.jsdelivr.net/gh/peasoft/NoMoreWalls@master/list.txt)
- [加速链接 3](https://cdn.staticaly.com/gh/peasoft/NoMoreWalls/master/list.txt)
- [加速链接 4](https://raw.kgithub.com/peasoft/NoMoreWalls/master/list.txt)
- [加速链接 2](https://ghproxy.net/https://raw.githubusercontent.com/peasoft/NoMoreWalls/master/list.txt)
- [加速链接 3](https://fastly.jsdelivr.net/gh/peasoft/NoMoreWalls@master/list.txt)
- [加速链接 4](https://cdn.staticaly.com/gh/peasoft/NoMoreWalls/master/list.txt)
- [加速链接 5](https://raw.kgithub.com/peasoft/NoMoreWalls/master/list.txt)

或添加 Clash 订阅:
- [原始链接](https://raw.githubusercontent.com/peasoft/NoMoreWalls/master/list.yml)
- [加速链接 1](https://ghproxy.com/https://raw.githubusercontent.com/peasoft/NoMoreWalls/master/list.yml)
- [加速链接 2](https://fastly.jsdelivr.net/gh/peasoft/NoMoreWalls@master/list.yml)
- [加速链接 3](https://cdn.staticaly.com/gh/peasoft/NoMoreWalls/master/list.yml)
- [加速链接 4](https://raw.kgithub.com/peasoft/NoMoreWalls/master/list.yml)
- [加速链接 2](https://ghproxy.net/https://raw.githubusercontent.com/peasoft/NoMoreWalls/master/list.yml)
- [加速链接 3](https://fastly.jsdelivr.net/gh/peasoft/NoMoreWalls@master/list.yml)
- [加速链接 4](https://cdn.staticaly.com/gh/peasoft/NoMoreWalls/master/list.yml)
- [加速链接 5](https://raw.kgithub.com/peasoft/NoMoreWalls/master/list.yml)

## 免责声明

Expand Down
94 changes: 47 additions & 47 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -640,53 +640,53 @@ rules:
- DOMAIN-KEYWORD,wikileaks,🚀 选择代理

# (Region-Restricted Access Denied)
- DOMAIN-SUFFIX,apartmentratings.com,🚀 选择代理
- DOMAIN-SUFFIX,apartments.com,🚀 选择代理
- DOMAIN-SUFFIX,bankmobilevibe.com,🚀 选择代理
- DOMAIN-SUFFIX,bing.com,🚀 选择代理
- DOMAIN-SUFFIX,booktopia.com.au,🚀 选择代理
- DOMAIN-SUFFIX,centauro.com.br,🚀 选择代理
- DOMAIN-SUFFIX,clearsurance.com,🚀 选择代理
- DOMAIN-SUFFIX,costco.com,🚀 选择代理
- DOMAIN-SUFFIX,crackle.com,🚀 选择代理
- DOMAIN-SUFFIX,depositphotos.cn,🚀 选择代理
- DOMAIN-SUFFIX,dish.com,🚀 选择代理
- DOMAIN-SUFFIX,dmm.co.jp,🚀 选择代理
- DOMAIN-SUFFIX,dmm.com,🚀 选择代理
- DOMAIN-SUFFIX,dnvod.tv,🚀 选择代理
- DOMAIN-SUFFIX,esurance.com,🚀 选择代理
- DOMAIN-SUFFIX,extmatrix.com,🚀 选择代理
- DOMAIN-SUFFIX,fastpic.ru,🚀 选择代理
- DOMAIN-SUFFIX,flipboard.com,🚀 选择代理
- DOMAIN-SUFFIX,fnac.be,🚀 选择代理
- DOMAIN-SUFFIX,fnac.com,🚀 选择代理
- DOMAIN-SUFFIX,funkyimg.com,🚀 选择代理
- DOMAIN-SUFFIX,fxnetworks.com,🚀 选择代理
- DOMAIN-SUFFIX,gettyimages.com,🚀 选择代理
- DOMAIN-SUFFIX,jcpenney.com,🚀 选择代理
- DOMAIN-SUFFIX,kknews.cc,🚀 选择代理
- DOMAIN-SUFFIX,nationwide.com,🚀 选择代理
- DOMAIN-SUFFIX,nbc.com,🚀 选择代理
- DOMAIN-SUFFIX,nordstrom.com,🚀 选择代理
- DOMAIN-SUFFIX,nordstromimage.com,🚀 选择代理
- DOMAIN-SUFFIX,nordstromrack.com,🚀 选择代理
- DOMAIN-SUFFIX,read01.com,🚀 选择代理
- DOMAIN-SUFFIX,superpages.com,🚀 选择代理
- DOMAIN-SUFFIX,target.com,🚀 选择代理
- DOMAIN-SUFFIX,thinkgeek.com,🚀 选择代理
- DOMAIN-SUFFIX,tracfone.com,🚀 选择代理
- DOMAIN-SUFFIX,uploader.jp,🚀 选择代理
- DOMAIN-SUFFIX,vevo.com,🚀 选择代理
- DOMAIN-SUFFIX,viu.tv,🚀 选择代理
- DOMAIN-SUFFIX,vk.com,🚀 选择代理
- DOMAIN-SUFFIX,vsco.co,🚀 选择代理
- DOMAIN-SUFFIX,xfinity.com,🚀 选择代理
- DOMAIN-SUFFIX,zattoo.com,🚀 选择代理
- DOMAIN,abc.com,🚀 选择代理
- DOMAIN,abc.go.com,🚀 选择代理
- DOMAIN,abc.net.au,🚀 选择代理
- DOMAIN,wego.here.com,🚀 选择代理
#USER-AGENT,Roam*,🚀 选择代理
- DOMAIN-SUFFIX,apartmentratings.com,🌐 突破锁区
- DOMAIN-SUFFIX,apartments.com,🌐 突破锁区
- DOMAIN-SUFFIX,bankmobilevibe.com,🌐 突破锁区
- DOMAIN-SUFFIX,bing.com,🌐 突破锁区
- DOMAIN-SUFFIX,booktopia.com.au,🌐 突破锁区
- DOMAIN-SUFFIX,centauro.com.br,🌐 突破锁区
- DOMAIN-SUFFIX,clearsurance.com,🌐 突破锁区
- DOMAIN-SUFFIX,costco.com,🌐 突破锁区
- DOMAIN-SUFFIX,crackle.com,🌐 突破锁区
- DOMAIN-SUFFIX,depositphotos.cn,🌐 突破锁区
- DOMAIN-SUFFIX,dish.com,🌐 突破锁区
- DOMAIN-SUFFIX,dmm.co.jp,🌐 突破锁区
- DOMAIN-SUFFIX,dmm.com,🌐 突破锁区
- DOMAIN-SUFFIX,dnvod.tv,🌐 突破锁区
- DOMAIN-SUFFIX,esurance.com,🌐 突破锁区
- DOMAIN-SUFFIX,extmatrix.com,🌐 突破锁区
- DOMAIN-SUFFIX,fastpic.ru,🌐 突破锁区
- DOMAIN-SUFFIX,flipboard.com,🌐 突破锁区
- DOMAIN-SUFFIX,fnac.be,🌐 突破锁区
- DOMAIN-SUFFIX,fnac.com,🌐 突破锁区
- DOMAIN-SUFFIX,funkyimg.com,🌐 突破锁区
- DOMAIN-SUFFIX,fxnetworks.com,🌐 突破锁区
- DOMAIN-SUFFIX,gettyimages.com,🌐 突破锁区
- DOMAIN-SUFFIX,jcpenney.com,🌐 突破锁区
- DOMAIN-SUFFIX,kknews.cc,🌐 突破锁区
- DOMAIN-SUFFIX,nationwide.com,🌐 突破锁区
- DOMAIN-SUFFIX,nbc.com,🌐 突破锁区
- DOMAIN-SUFFIX,nordstrom.com,🌐 突破锁区
- DOMAIN-SUFFIX,nordstromimage.com,🌐 突破锁区
- DOMAIN-SUFFIX,nordstromrack.com,🌐 突破锁区
- DOMAIN-SUFFIX,read01.com,🌐 突破锁区
- DOMAIN-SUFFIX,superpages.com,🌐 突破锁区
- DOMAIN-SUFFIX,target.com,🌐 突破锁区
- DOMAIN-SUFFIX,thinkgeek.com,🌐 突破锁区
- DOMAIN-SUFFIX,tracfone.com,🌐 突破锁区
- DOMAIN-SUFFIX,uploader.jp,🌐 突破锁区
- DOMAIN-SUFFIX,vevo.com,🌐 突破锁区
- DOMAIN-SUFFIX,viu.tv,🌐 突破锁区
- DOMAIN-SUFFIX,vk.com,🌐 突破锁区
- DOMAIN-SUFFIX,vsco.co,🌐 突破锁区
- DOMAIN-SUFFIX,xfinity.com,🌐 突破锁区
- DOMAIN-SUFFIX,zattoo.com,🌐 突破锁区
- DOMAIN,abc.com,🌐 突破锁区
- DOMAIN,abc.go.com,🌐 突破锁区
- DOMAIN,abc.net.au,🌐 突破锁区
- DOMAIN,wego.here.com,🌐 突破锁区
#USER-AGENT,Roam*,🌐 突破锁区

# (The Most Popular Sites)
# > Apple
Expand Down
41 changes: 35 additions & 6 deletions fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import binascii
import threading
import sys
import os
from types import FunctionType as function
from typing import Set, List, Dict, Union, Any

Expand Down Expand Up @@ -67,6 +68,8 @@ def b64decodes_safe(s):

FETCH_TIMEOUT = (6, 5)

DEBUG_NO_NODES = os.path.exists("local_NO_NODES") # !!! JUST FOR DEBUGING !!!

class UnsupportedType(Exception): pass
class NotANode(Exception): pass

Expand Down Expand Up @@ -519,7 +522,7 @@ def merge(source_obj: Source, sourceId=-1) -> None:
def raw2fastly(url: str) -> str:
# 由于 Fastly CDN 不好用,因此换成 ghproxy.net,见 README。
# 2023/06/27: ghproxy.com 比 ghproxy.net 稳定性更好,为避免日后代码失效,进行修改
# 2023/06/28: ghproxy.com 似乎有速率限制,改回原来的镜像
# 2023/06/28: ghproxy.com 似乎有速率或并发限制,改回原来的镜像
# url = url[34:].split('/')
# url[1] += '@'+url[2]
# del url[2]
Expand All @@ -534,6 +537,10 @@ def main():
global exc_queue, FETCH_TIMEOUT
from dynamic import AUTOURLS, AUTOFETCH, set_dynamic_globals
sources = open("sources.list", encoding="utf-8").read().strip().splitlines()
if DEBUG_NO_NODES:
# !!! JUST FOR DEBUGING !!!
print("!!! 警告:您已启用无节点调试,程序产生的配置不能被直接使用 !!!")
AUTOURLS = AUTOFETCH = sources = []
if PROXY: session.proxies = {'http': PROXY, 'https': PROXY}
session.headers["User-Agent"] = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.58'
print("正在生成动态链接...")
Expand Down Expand Up @@ -681,17 +688,37 @@ def main():
blocked.add(line.strip('al').strip('|^$'))
adblock_rules: List[str] = []
for domain in blocked:
if domain.count('.') == 3 and domain.replace('.','').isdigit(): # IP
adblock_rules.append(f"IP-CIDR,{domain}/32,{conf['proxy-groups'][-1]['name']}")
segs = domain.split('.')
if len(segs) == 4 and domain.replace('.','').isdigit(): # IP
for seg in segs: # '223.73.212.020' is not valid
if not seg: break
if seg[0] == '0' and seg != '0': break
else:
adblock_rules.append(f"IP-CIDR,{domain}/32,{conf['proxy-groups'][-1]['name']}")
else:
adblock_rules.append(f"DOMAIN-SUFFIX,{domain},{conf['proxy-groups'][-1]['name']}")
print(f"共有 {len(adblock_rules)} 条规则")

print("正在写出 Clash 订阅...")
rules = conf['rules']
rules2 = list(set(rules))
rules2.sort(key=rules.index)
conf['rules'] = adblock_rules + rules2
rules2 = {}
match_rule = None
for rule in rules:
tmp = rule.strip().split(',')
if len(tmp) == 2 and tmp[0] == 'MATCH':
match_rule = rule
break
if len(tmp) == 3:
rtype, rargument, rpolicy = tmp
elif len(tmp) == 4:
rtype, rargument, rpolicy, rresolve = tmp
rpolicy += ','+rresolve
else: print("规则 '"+rule+"' 无法被解析!")
k = rtype+','+rargument
if k not in rules2:
rules2[k] = rpolicy
rules3 = [','.join(_) for _ in rules2.items()]+[match_rule]
conf['rules'] = adblock_rules + rules3
conf['proxies'] = []
names_clash: Set[str] = set()
for p in merged:
Expand All @@ -705,6 +732,8 @@ def main():
with open("list.yml", 'w', encoding="utf-8") as f:
f.write(yaml.dump(conf, allow_unicode=True).replace('!!str ',''))

# print("正在写出配置片段...")

print("正在写出统计信息...")
out = "序号,链接,节点数\n"
for i, source in enumerate(sources_obj):
Expand Down

0 comments on commit ceac2e2

Please sign in to comment.