Update to EdgeRouter Lite-3 and Adblocking

If you’re using the guide I wrote in my previous post, a recent change in one of the adblock lists started blocking Spotify. Given my ravenous use of both Spotify and Tidal, that’s unacceptable.

Here’s an updated version of the script that uses sed to remove the Spotify domain that was blocked.

# get two hosts files with adress, extract out only ad blocking lists and write them to a temporary file
curl -s “http://hosts-file.net/ad_servers.txt" “http://www.malwaredomainlist.com/hostslist/hosts.txt" | grep -w ^$’\(\t\| \)’ | sed ‘s/^\s\{1,\}//’ > $temp_ad_file
# get another two hosts files with adress, extract out only ad blocking lists, remove whitespace at the end of some lines and output it to temp
curl -s “http://winhelp2002.mvps.org/hosts.txt" “http://someonewhocares.org/hosts/zero/hosts" | grep -w ^ | cut -c 9- | sed ‘s/\s\{1,\}.*//’ >> $temp_ad_file
# remove the carriage return at the end of each line of the temporary file, and convert it into a Dnsmasq format
sed -i -e ‘s/\r$//; s:.*:address=/&/0\.0\.0\.0:’ $temp_ad_file
# get another hosts file in Dnsmasq format, and add the contents to a temporary file
curl -s “http://pgl.yoyo.org/adservers/serverlist.php?hostformat=dnsmasq&showintro=0&mimetype=plaintext&useip=" >> $temp_ad_file
if [ -f “$temp_ad_file” ]
# a pseudo whitelist
sed -i -e ‘/spclient\.wg\.spotify\.com/d’ $temp_ad_file
# sort ad blocking list in the temp file and remove duplicate lines from it
sort -o $temp_ad_file -t ‘/’ -uk2 $temp_ad_file
# uncomment the line below, and modify it to remove your favorite sites from the ad blocking list
#sed -i -e ‘/www\.favoritesite\.com/d’ $temp_ad_file
mv $temp_ad_file $ad_file
echo “Error building the ad list, please try again.”
/etc/init.d/dnsmasq force-reload

Note the line with spclient.wg.spotify.com on it.