@@ -5,7 +5,7 @@ HOSTS_FILE="hosts.md"
55start_time=$( date +%s)
66
77current_time () {
8- date +" %H:%M:%S"
8+ date +" %H:%M:%S"
99}
1010
1111blocklists=(" abuse" " vaping" " torrent" " scam" " ransomware" " porn" " piracy" " phishing" " malware" " fraud" " drugs" )
@@ -14,7 +14,7 @@ blocklists_count=${#blocklists[@]}
1414echo -e " \e[34m[\e[90m$( current_time) \e[34m] Downloading $blocklists_count blocklists\e[0m"
1515
1616for list in " ${blocklists[@]} " ; do
17- wget -q " https://blocklistproject.github.io/Lists/${list} .txt" -O " ${list} .txt" &
17+ wget -q " https://blocklistproject.github.io/Lists/${list} .txt" -O " ${list} .txt" &
1818done
1919wait
2020
@@ -29,18 +29,18 @@ sort -u combined_blocklist.txt -o combined_blocklist.txt
2929echo -e " \e[32m[\e[90m$( current_time) \e[32m] Blocklists combined\e[0m"
3030
3131save_domain_entry () {
32- local domain=$1
33- local rule_count=$2
34- local count=$3
35- local total_domains=$4
36- local unicode_domain=$( idn --idna-to-unicode " $domain " )
37- local favicon_url=" https://icons.duckduckgo.com/ip3/${domain} .ico"
38- if wget -q --spider " $favicon_url " ; then
39- echo " - <img src=\" ${favicon_url} \" width=\" 16\" loading=\" lazy\" /> ${unicode_domain} (${rule_count} )" >> " $HOSTS_FILE "
40- else
41- echo " - ${unicode_domain} (${rule_count} )" >> " $HOSTS_FILE "
42- fi
43- echo -e " \e[35m[\e[90m$( current_time) \e[35m] $count / $total_domains - \e[34m\e[4m${unicode_domain} \e[0m\e[0m"
32+ local domain=$1
33+ local rule_count=$2
34+ local count=$3
35+ local total_domains=$4
36+ local unicode_domain=$( idn --idna-to-unicode " $domain " )
37+ local favicon_url=" https://icons.duckduckgo.com/ip3/${domain} .ico"
38+ if wget -q --spider " $favicon_url " ; then
39+ echo " - <img src=\" ${favicon_url} \" width=\" 16\" loading=\" lazy\" /> ${unicode_domain} (${rule_count} )" >> " $HOSTS_FILE "
40+ else
41+ echo " - ${unicode_domain} (${rule_count} )" >> " $HOSTS_FILE "
42+ fi
43+ echo -e " \e[35m[\e[90m$( current_time) \e[35m] $count / $total_domains - \e[34m\e[4m${unicode_domain} \e[0m\e[0m"
4444}
4545
4646# Extract affected hosts and filter against blocklist
@@ -56,12 +56,12 @@ echo -e "# Affected hosts ($total_domains)\n\n" > "$HOSTS_FILE"
5656count=0
5757
5858for domain in $domains ; do
59- count=$(( count + 1 ))
60- if ! grep -q " ^${domain} $" combined_blocklist.txt; then
61- rule_count=$( grep -c " ^${domain} ##" " ${FILENAME} " )
62- save_domain_entry " $domain " " $rule_count " " $count " " $total_domains "
63- affected_hosts+=(" $domain " )
64- fi
59+ count=$(( count + 1 ))
60+ if ! grep -q " ^${domain} $" combined_blocklist.txt; then
61+ rule_count=$( grep -c " ^${domain} ##" " ${FILENAME} " )
62+ save_domain_entry " $domain " " $rule_count " " $count " " $total_domains "
63+ affected_hosts+=(" $domain " )
64+ fi
6565done
6666
6767affected_hosts_count=${# affected_hosts[@]}
@@ -70,7 +70,7 @@ echo -e " \e[32m[\e[90m$(current_time)\e[32m] $affected_hosts_count affected hos
7070# Clean up
7171rm -f combined_blocklist.txt
7272for list in " ${blocklists[@]} " ; do
73- rm -f " ${list} .txt"
73+ rm -f " ${list} .txt"
7474done
7575
7676end_time=$( date +%s)
0 commit comments