Skip to content

Commit

Permalink
support for regexes with ublacklist
Browse files Browse the repository at this point in the history
  • Loading branch information
NotaInutilis committed Feb 22, 2024
1 parent 8de0f17 commit 9526f30
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 0 deletions.
9 changes: 9 additions & 0 deletions scripts/ublacklist.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,18 @@
linesurls = urls.readlines()
blocklist = linesdomains + linestlds + linesurls

with open("sources/regex_addresses.txt", "r") as addresses:
linesaddresses = titles.readlines()
with open("sources/regex_titles.txt", "r") as titles:
linestitles = titles.readlines()

# Print blocklist
for line in linesheader:
print(line.strip())
print()
for line in blocklist:
print('*://*.' + line.strip() + '/*')
for line in linesaddresses:
print(line.strip())
for line in linestitles:
print('title/' + line.strip() + '/i')
4 changes: 4 additions & 0 deletions scripts/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ find ./sources/domains -type f -iname "*fediverse*.txt" -exec cat {} \; > ./sour
find ./sources/urls -type f -iname "*.txt" -exec cat {} \; > ./sources/urls.txt
### TLDs
find ./sources/tlds -type f -iname "*.txt" -exec cat {} \; > ./sources/tlds.txt
### Regex addresses
find ./sources/regex_addresses -type f -iname "*.txt" -exec cat {} \; > ./sources/regex_addresses.txt
### Regex titles
find ./sources/regex_titles -type f -iname "*.txt" -exec cat {} \; > ./sources/regex_titles.txt

## Cleanup the lists
### Remove comments, inline comments, spaces and empty lines
Expand Down
4 changes: 4 additions & 0 deletions sources/regex_addresses/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
https://help.adblockplus.org/hc/en-us/articles/360062733293-How-to-write-filters#regexps
https://github.com/gorhill/uBlock/wiki/Regular-expression-based-filters
https://iorate.github.io/ublacklist/docs/advanced-features#regular-expressions
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
2 changes: 2 additions & 0 deletions sources/regex_titles/Clickbait.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Spoilers!
/ending explained/i
1 change: 1 addition & 0 deletions sources/regex_titles/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://iorate.github.io/ublacklist/docs/advanced-features#regular-expressions-for-page-titles

0 comments on commit 9526f30

Please sign in to comment.