Adblocker/create-adblock.sh

36 lines
830 B
Bash
Raw Normal View History

2023-07-21 21:37:00 +00:00
#!/bin/bash
echo "" > pre-adblock.txt
#Adblock lists download
2023-07-21 21:37:00 +00:00
while read p; do
echo "#!MARKER- Begin of $p" >> pre-adblock.txt
wget -qO - $p >> pre-adblock.txt
sleep 2
2023-07-21 21:37:00 +00:00
done <adblocklists.txt
# Breaking before will cause trouble if a URL is not reachable
set -e -u
2023-07-21 21:37:00 +00:00
date=$(date '+%a, %d %b %Y %H:%M:%S %z')
2023-07-24 21:03:45 +00:00
#Remove comments in lists
sed -i 's/^!.*$//g' pre-adblock.txt
#Change marker to comment
sed -i 's/#!MARKER-/!/g' pre-adblock.txt
2023-07-24 21:03:45 +00:00
#Create Header
echo '! Title: Mainboarder compiled
2023-07-21 21:37:00 +00:00
! Description: Filters optimized for uBlock, for single list use, deduplicated
! Expires: 2 days
! Last modified: '"$date"'
2023-07-24 20:48:53 +00:00
! Homepage: https://git.mainboarder.de/Public/Adblocker
2023-07-21 21:37:00 +00:00
!' > all-adblock.txt
#Add own rules
2023-07-24 21:03:45 +00:00
cat own-rules.txt >> all-adblock.txt
#Remove duplicate lines
awk '!seen[$0]++' pre-adblock.txt >> all-adblock.txt