improve blocklist generation script

This commit is contained in:
Peter Cai 2021-04-05 20:50:02 +08:00
parent 9dca8f1a89
commit 006603de0f
1 changed files with 3 additions and 1 deletions

View File

@ -2,7 +2,9 @@
function import_hosts() {
local url=$1
curl "$url" | sed '/^#/d' | sed 's/0.0.0.0 //g' | sed 's/127.0.0.1 //g' | grep '\S'
# Trim lines, remove comments, convert tabs to spaces, collapse multiple spaces, and
# take the second column of the output
curl "$url"| sed -E 's/^[ \t]+//g' | sed '/^#/d' | sed 's/\t/ /g' | sed -E 's/[ ]+/ /g' | cut -d ' ' -f 2 | grep '\S'
}
# In blocklist_config, put a list of URLs to shared ad-blocking hosts files