Assumption is that user wants page to load faster but does not object to tracking.
What if user wants page to load faster and objects to tracking?
Source of Firefox tracking protection is list at disconnect.me?
credit: eco https://news.ycombinator.com/item?id=15964393
Basic gethostbyname()->HOSTS file blocking:
#!/bin/sh
exec curl https://disconnect.me/trackerprotection/blocked \
|sed -n '/<\/br>/!{/\./s/^/255.255.255.255 /;};/\./p' >> /etc/hosts;
User may want to add these too:
https://disconnect.me/trackerprotection/unblocked
Beyond HOSTS file, authoritative DNS gives more flexibility, e.g. logging all requests, using wildcards, etc. For example, tinydns: #!/bin/sh
curl https://disconnect.me/trackerprotection/blocked \
|sed -n '/<\/br>/!{/\./s/.*/.&\
=&:255.255.255.255:1/;};/\./p' >> _root.zone/root/data;
if cd _root.zone/root/data;then exec tinydns-data;fi
Or dnscache: #!/bin/sh
curl https://disconnect.me/trackerprotection/blocked \
|sed -n '/<\/br>/!{
/\./s/.*/echo 255.255.255.255 > _dnscache\/root\/servers\/& /;};
/\./p' > block.sh;
if sh -c ./block.sh;then exec rm block.sh;fi
Note I am not recommending this particular block list. Compared to the one I use, it seems incomplete. I prefer to create own list from DNS logs from own network traffic. Use of wildcards can shorten a long list like this substantially.