Adblocker/create-adblock.sh

36 lines
830 B
Bash
Executable file

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