Skip to content

Commit

Permalink
add Adblock
Browse files Browse the repository at this point in the history
  • Loading branch information
elysias123 committed Feb 7, 2024
1 parent 3f554cc commit 62be8da
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
python main.py
cd out
mkdir Filters
mv AWAvenue-Ads-Rule-Adguard.txt AWAvenue-Ads-Rule.txt #历史遗留问题
cp -Rf AWAvenue-Ads-Rule-Adblock.txt AWAvenue-Ads-Rule.txt #历史遗留问题
mv AWAvenue-Ads-Rule-* Filters/
cd Filters
wget -O ./sing-box.tar.gz https://github.com/SagerNet/sing-box/releases/download/v1.8.2/sing-box-1.8.2-linux-amd64.tar.gz
Expand Down
23 changes: 23 additions & 0 deletions script/Adblock.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
def format_domain(domain_file):
domain = []
with open(domain_file, 'r') as file:
lines = file.readlines()
for line in lines:
domain_lines = f"||{line.strip()}^"
domain.append(domain_lines)
return domain


def format_regex(regex_file):
regex = []

with open(regex_file, 'r') as file:
lines = file.readlines()
for line in lines:
regex_lines = f"/{line.strip()}/".replace("\.","\\\.").replace("\*","\.\*")
regex.append(regex_lines)
return regex

def build(domain_file, regex_file):
Adblock_list = format_domain(domain_file) + format_regex(regex_file)
return Adblock_list

0 comments on commit 62be8da

Please sign in to comment.