Hello,
my most promising solution for ad block is the modification of the hosts file. AdBlocking on Sailfish OS via /etc/hosts | dt.iki.fi developed a suitable solution. However for me it was still very complicated to process all the steps. Therefore I wrote a bash script that includes all steps.
There’s nothing wrong with using a single hosts file, but I wanted to go the extra mile, as discussed in this thread.
Therefore the script has grown quite complex:
it converts uBO’s uAssets as far as possible to be used by /etc/hosts
it downloads everything from firebog.net’s meta list plus Steven Black’s largest hosts file
it combines and unique-sorts everything, adds a header and finally overwrites the old /etc/hosts
My tutorial mostly describes how to make updates automatic; the script itself can be treated as opaque.
Thanks to @FelixWilke for automating that in turn, and directly linking to my script. If you want you can use this link instead and I’ll try my best to make sure not to break compatibility in future updates.
I may have misused chum metadata, I can edit that later. One thing I am not comfortable with is that I placed the rpm folder inside the hosts folder, which might prevent a chum build on OBS, maybe I should stick to a top-level rpm dir…
Still, if you checkout that repo, cd hosts and sfdk build you’d get a rpm.
I’m not an expert but looking at this script, I perceive it as something missing. As far as I know, you need reboot for updated hosts list to take effect? Don’t you?
Changes to the /etc/hosts file are usually picked up immetiately without a reboot. Just give it a try by changing some IP and use ping to trigger hostname resolution.
With these steps I get the result you describe als on 4.6.0.15 but the reason is probably, that the browser uses its own resolver. After a pkill -f browser that should have killed sailfish-browser as well as browser-booster, the changes are picked up without a reboot.
Yes, if that really is working. As I said, I didn’t test.
I imagine that browser is the real world use case, so I would want the hosts file to apply without having to reboot… or being prompted to reboot… or choose a 100% working solution, even if it’s a bit manually.
I haven’t checked yet because I have other problems to solve first with C2, but I wonder if without an app it might work by modifying the host file. CF: DNS Block List [Wiki de sebsauvage.net]
Of course, you do not need an app (or script) to make the hosts file work as a block list.
Me, myself is using a simple command which I manually execute now and then… maybe once a month.
I also made the command a quick launcher in my app drawer using the qCommand app.
The personal command of mine is… devel-su curl https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/gambling-social/hosts -o /etc/hosts && pkill -f browser
…but of course you can use any list URL of your choice.
If qCommand is already root one can reboot or killall browsers anyway.
Speaking of systemd, if you have a timer based service to update hosts, it would be weird that once a week, say, your browser or phone restarts (the latter is dangerous since unattended restarts mean also inability for alarms to work)
I think in this latter case a notification that restarts the browser at will would be a solution, but that is deterred by the fact that you’re root (the notification…)