From 006603de0fc1aebbcb719fdbc6dbd9ae9db381a8 Mon Sep 17 00:00:00 2001 From: Peter Cai Date: Mon, 5 Apr 2021 20:50:02 +0800 Subject: [PATCH] improve blocklist generation script --- generate_blocklist.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/generate_blocklist.sh b/generate_blocklist.sh index 2bbab6c..0baa346 100755 --- a/generate_blocklist.sh +++ b/generate_blocklist.sh @@ -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