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

Reading a post by @GreatJoe 's experience as a new SFOS user highlighted that there currently seems to be no easy solution for ad blocking in SFOS for regular users. From what I could crowd-source and found on this forum, these are our options:

  1. Hosts Adblock
    Working Status: Seems broken from SFOS 4.4
    Covers: SFOS and Android App Support
    Pros: Set and forget, very simple program/script
    Cons: No AARCH64 version, Possible Sailjail issues, Unmaintained/Abandoned

  2. Defender II
    Working Status: Unknown/Unclear
    Covers: SFOS and Android App Support
    Pros: Set and forget, GUI based, user-friendly
    Cons: Have boot-looped devices in the past etc.

  3. Hosty
    Working Status: Working
    Covers: SFOS
    Pros: It works
    Cons: Install by running a foreign script as root, hosty as cron job runs as root (Possible Security/Privacy implications), Not exactly user-friendly to regular users

  4. AdBlocking on Sailfish OS via /etc/hosts
    Working Status: Working
    Covers: SFOS and Android App Support
    Pros: No extra dependancies to be installed, simple solution (Unlikely to cause issues with SFOS updates?)
    Cons: Not exactly user-friendly to regular users

  5. Just curl a blocklist to hosts file
    Working Status: Working
    Covers: SFOS only (But can be both with symlinc)
    Pros: No extra dependancies to be installed, simple solution (Unlikely to cause issues with SFOS updates?)
    Cons: Not exactly user-friendly to regular users

  6. Privoxy
    Working Status: Working
    Covers: SFOS and Android App Support
    Pros: Extremely powerful solution
    Cons: Setup and config is difficult (Or maybe not…)(Not for regular user), possibly touching many SFOS system files and configs (Might cause issues with SFOS updates?)

  7. DNScrypt-proxy blocklist (DNS alternative)
    Working Status: Working
    Covers: SFOS and Android App Support
    Pros: Much more control and many additional features
    Cons: Not exactly user-friendly to regular users, possibly touching many SFOS system files and configs (Might cause issues with SFOS updates?)

  8. Android Firefox-based browser with uBlock Origin
    Working Status: Working
    Covers: Browser only
    Pros: User-friendly
    Cons: Only works in the browser it’s installed in (Not system wide)

Disclaimer: The list above is entirely based on my own opinion and research and may, and probably do, contain errors. There might be other possible solutions I have not found and thus they do not appear in the list above. Hosts-based solutions seem to require a reboot of the phone before the updated hosts-file is used and no solution to this has been proposed.

So here is the question: What solution has the lowest risk and easiest set up? What solution do you use or would recommend?

P.S. I have used solution 1 for nine years on a Jolla 1 without issues. For newer devices, I’m not sure…

EDIT: I do not endorse any specific solution, nor have I tested all of these, YMMV

9 Likes

I’m using solution 4 since Defender is not working properly anymore…
I’m missing it!

1 Like

Testing Privoxy on Volla…
Installed everything from Chum (Privoxy, AdBlock configuration, Docs, http server and tools) and rebooted. It installed 2 new icons on app grid, and Privoxy Config did nothing and Privoxy Toggle showed something about a proxy 127.0.0.1 port 8118 not installed or so.

After I entered this proxy into Settings/System/Mobile Network/Advanced/Proxy 1, the 2 new icons on app grid show:
Privoxy Config: Privoxy Menu (6 items) + Support and Service.
Privoxy Toggle: Privoxy is enabled

My observation: clean sites load much faster but ‘less clean’ ones showing no images now. So for me this means that Privoxy works…
working and faster: Youtube, orf.at, de.m.wikipedia.org, hpmuseum.org, hpcalc.org
Not working: la-palma24.info - reports: Unable to connect, Browser can’t establish connection to googleads.g.doubleclick.net, that means that it works as it should. :star_struck:
edit: images come after two minutes.

Have to say, it’s not sooo difficult.

I’m curious and will report if some annoying effects will occur.

Thank you @nephros ! And Thank you @Novacane for the list!

edit: installation also successful on Xperia 10. Thanks again!

edit: Blocking does also work if phone is used as mobile access point. Annoying advertisement also filtered on laptop connected to Hotspot. Pages load noteable faster but sometimes also content is missing.

1 Like

Option 5.
The browser is basically the only thing that has ads in sfos so there’s no need for anything else for me.
Android browsers already have Adblock or can be installed as a plugin.
For YouTube I use microtube that doesn’t show ads and also has sponsorblock.

With “Setup and config is difficult” I meant the instructions seemed a bit convoluted or unclear (Which I think your reply proves :wink: ). Also, if this breaks something somewhere in SFOS, a regular user might not easily be able to fix their system…

1 Like

True, but other Android apps can load all kinds of garbage in the background…

Microtube is the way to go, good tip.

Did I make something wrong?

For that you can try this, method number 2.

Other than that, I assume ReVanced manager should work here too. It’s a tool to apply different types of patches in apps like YouTube, Twitch, Spotify and some social.

2 Likes

You are invited to make a pull request with changes to the README, or cook up your own guide which I can link to,or any other suggestions you have, in order to make this better.

Just to manage expectations though: privoxy can not and will not ever be a one-klick-it-works kind of app. By nature of the software you have to have some knowledge how it works, how websites etc work.
Knowing what you’re doing also reduces the chances of something breaking. (In fact the reason I’m giving hands-on instructions in text form instead of doing this somehow automatically is done intentionally to lower the risk of breakage.)

Also, please understand that my goal or role in all of this is not to provide a “privacy app” or “adblocking solution”.
My role is packaging the upstream software so it runs on SFOS, with minimal modifications. And I add some SFOS-specific add-ons that I think are useful (like the preconfigured ab2p infrastructure and config, some housekeeping stuff, etc.). This is what I can do, this is what I can support, not more.

This is not elitism I believe, as @GreatJoe suggests, it is due to the fact that Privoxy is supposed to be run on a server-type machine, which a admin-type person who configures it for their users.
Coaxing it onto a phone and make it block stuff is possible thanks to the wonderfulness of Linux, but setting it up it does involve the same admin-type tasks.


Anyway, apart from installation and initial setup, if anyone has something running in Privoxy they are very much invited to share their config hacks and snippets in this thread or through the source repo and hopefully the rules shipped with it can be improved for everybody.

5 Likes

I meant no offense, nor did I mean to imply anything more than that this solution is not meant for a “regular” user (The adage “never run commands you don’t understand” comes to mind). I do not agree with @GreatJoe calling this elitism, and I agree with your statement “Knowing what you’re doing also reduces the chances of something breaking.” I would add to that “Knowing what you’re doing also enables you to fix something if it breaks.”

Thanks for all your effort in the community

No, nothing wrong :smile:
I just meant that this solution is not for a “regular” user. Also see my response to @nephros below

1 Like

As I’m using SailfishOS daily now I immediately encountered this problem and I’ve solved it by using Blocky (it’s like Pi-Hole or AdGuard).

I’ve now released a UI for it. I had bigger plans for my first release (like YAML validation or hosts lists reload, etc…), but I want to share it anyway at this stage as this thread is a bell that other people may need it.

Working Status: Alpha release. Disables connman DNS functionality and enable blocky. It’s possible to edit the configuration from the UI, but if you make any error you are screwed (delete ~/.config/dev.scarpino/harbour-blocky/blocky.yaml to start with the default config).
Covers: SFOS and Android App Support (? I guess, I don’t use it)
Pros: Set and forget.
Cons: No i486 version (missing upstream), runs as root (needed to restart blocky).

9 Likes

It does not download blacklist updates also from wifi and moreover I cannot disable wifi-only option. I am using 4.5.0.19 for Xperia 10 II.

This is probably the simplest solution especially used in combination with dnsmasq or DNS Alternative. There is also another provider that offer a similar service: Quad9 therefore the best combination is to alternate the two services in the DNS queries, like in the following:

  • IPv4: 9.9.9.9, 94.140.14.14, 149.112.112.112, 94.140.15.15

  • IPv6: 2620:fe::fe , 2a10:50c0::ad1:ff, 2620:fe::9, 2a10:50c0::ad2:ff

This is an example of /etc/resolv.conf for every host connected with an IPv4 + IPv6 network which alternates AdGuard and Quad9 ad-blocking and safe-filtered DNS .

#IPv4 nameservers
nameserver  9.9.9.9 
nameserver  94.140.14.14
nameserver  149.112.112.112
nameserver  94.140.15.15

#IPv6 nameservers
nameserver  2620:fe::fe
nameserver  2a10:50c0::ad1:ff
nameserver  2620:fe::9
nameserver  2a10:50c0::ad2:ff

Usually the /etc/resolv.conf is not the right place to insert these value, anyway.

1 Like

Hey, just wanted to share what I am doing:

  • a orange Pi Pc at home with pihole and pivpn set up (setup is a guided step by step and very easy)
  • every time the phone activates cellular or wifi it automatically connects to my VPN, which blocks ads at the system level

Cons:

  • pi needs to be working 24/7, as well as my internet connection at home

So if you happen to have and old board, you can use it. Just mind the electricity bill, if you are using an old laptop or PC :slight_smile:

1 Like