Page 1 of 1

Fine-tuning block-advert.sh

Posted: Mon Aug 11, 2025 12:57 am
by MikeR
On my internet-connected Linux (plural Linii?) I installed block-advert which is a great help in cutting down adverts and other unwanted slop. (advert-block-antix in synaptic)
However the blocking was slightly too strict as I lost access to a couple of addresses that I wanted to reach.
My solution was as follows:
1. open /usr/local/bin/block-advert.sh in your editor of choice.
2. after the second occurrence of the line "====================YTO"
added the lines:
echo "Modify $WORKINGDIR/blocklist-all: Remove whatsapp & reddit (Mike)"
grep -v whatsapp $WORKINGDIR/blocklist-all | grep -v reddit > $WORKINGDIR/blocklist-all2
mv $WORKINGDIR/blocklist-all2 $WORKINGDIR/blocklist-all
(On my copy of /usr/local/bin/block-advert.sh this came at line 83)
N.B. Obviously change my choices reddit and whatsapp to your own preference, add whatever, and you can skip Mike or replace with a string that you can easily search

HTH,
Mike

Re: Fine-tuning block-advert.sh

Posted: Mon Aug 11, 2025 4:26 pm
by m_pav
Interesting, I've been using advert-block-antix for quite a few years now and neither whatsapp nor reddit are blocked. They do show up in my /etc/hosts file, but only elements of such, not the primary site url. IIRC, I did have troubles with reddit when I had selected all options, and when I re-ran it without the porn blockers, I could use both.

That being said, URL blocking is losing ground to DNS hacks that bypass the former.

The hosts file has 24800 lines and each line contains roughly 9 site urls, so excluding the first 14 lines, that would give ~251-252K blocked sites.

Obviously, the volume of blocked sites will be determined by what options you choose when running the script, but it would be interesting to see how yours differs in line numbers.

Re: Fine-tuning block-advert.sh

Posted: Mon Aug 11, 2025 10:16 pm
by MikeR
@m_pav
$ dir /etc/hosts
-rw-r--r-- 1 root root 4.8M Aug 11 06:49 /etc/hosts
$ wc -l /etc/hosts
26067 /etc/hosts
Did not include porn and gambling lists
Without the added lines I could not access (some, possibly not all) reddit addresses, or run whatsapp screen app.

Mike