Adblocker/create-adblock.sh

41 lines
932 B
Bash
Raw Normal View History

2023-07-21 21:37:00 +00:00
#!/bin/bash
touch pre-adblock.txt
touch errors.log
date=$(date '+%a, %d %b %Y %H:%M:%S %z')
#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
if [ $? -ne 0 ]; then
echo "$date - Download failed: $p" >> errors.log
fi
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
#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