Ad blocking in SailfishOS in 2023 - What are the options?

Ok, @eson, try this mouthful of command at the end of the script

notificationtool -o add -a "restart;Restart org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager RestartUnit booster-browser@sailfish-browser.service replace" "Adblock Hosts updated" "Click Restart to restart browser." -A hosts-block -I icon-l-calendar-cancelled

This does not restart the browser, but shows a notification that kills it if you so wish, you restart it yourself.

2 Likes

Thanks, but I do not wish to use that script at all. I’m very happy with my simple solution.
However, I did a quick test on the @martinh command ( pkill -f browser), and it actually works to apply the updated hosts file without reboot.

2 Likes

Simplest native AdBlock solution, since we only see ads in the browser (works for me on C2):
Edit DoH settings in about:config.

  1. Enter about:config in address bar, swipe to accept
  2. Scroll all the way down to network.trr.default_provider_uri
  3. Replace the cloudflare DNS url with one from this list https://github.com/curl/curl/wiki/DNS-over-HTTPS
  4. Scroll further down to network.trr.mode
  5. Set it to 3 (always use DoH)
  6. Tap accept

Then test at some AdBlock Test Site If it works.

13 Likes

Unfortunately ads will also be shown in Android Apps. Therefore I use the firewall to redirect remote traffic to port 53 to an ad-blocking DNS.

2 Likes

I have accepted one PR from @vlagged and another is in the pipeline.

Sorry, work has been hell for 3 weeks now. And today I physically broke my phone, so getting a new one takes priority. I guess in a few days I have time to figure out how @vlagged’s contrib results in a usable software package, and how to make the script even more robust! Possibly even configurable.

Just a quick reminder, the package includes a systemd service file that executes the script.

It’s in Chum:testing now! Dedicated thread.

2 Likes

Thanks a lot . Can anyone recommend the best dns to use to block ads? I am using AdGuard at the moment.

Is the hosts block a better option in blocking ads or it breaks sites ?

Update: I installed hosts-block from storeman and it works great, even better than the dns approach via browser

Better use the Chum version to which I can push updates; I’m not connected to the Storeman version.

Is the hosts block a better option in blocking ads or it breaks sites ?

Adblocking via DNS or /etc/hosts essentially works the same way.

Thanks for the info. I have used the hosts approach but i seem to be getting ads in android. Shouldn’t the hosts block ads in android as well? It works fine in default browser

If I remember correctly, you should ad your hosts list also to /system/etc/hosts, to make it work also in android.
At least that was the case some years ago.

1 Like
1 Like