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

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.

7 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

1 Like

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).

10 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.

2 Likes

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

I still use a simple systemd timer to download a hosts file to /etc/hosts, as described (and now updated) here, incl. bind-mount on Android.

6 Likes

Hey, @ohnonot thank you so much for your Instruction. Finally I did manage to ban ads from my browser. I makes a real difference in performance.

A short notice for others: Your instructions are not for newbies. It was necessary to do several additional steps to set up the system correctly.

I can reproduce the following code and modify hosts.timer and hosts.service as described :

> cd /etc/systemd/system
> nano hosts.timer hosts.service
> systemctl daemon-reload
> systemctl enable hosts.timer

During the next steps, however, I got lost.
Putting the following in the terminal:
~/.local/bin/hosts
results in an error (no such file/directory exists)
I had to create the file first.
the same goes with hosts.head (I needed to create the file first, and have to chance the permissions second)

2 Likes

Thanks for your feedback! It is much appreciated.

  • I have changed the article so that the script resides in /usr/local/bin/hostsupdate instead of the user’s home directory, and gave it a better name. It makes more sense this way.
  • the necessity of hosts.head being present beforehand (and created manually) is mentioned in the article. I cannot automate ths process without complicated checks and taking the user’s freedom to have a customised hosts file (i.e. the head portion of it) but I added a check to the script that will make it fail if that file is not present.
  • Yes some preliminaries are required but tbf, it is possible to do everything on the device, without ssh.
5 Likes

I just used your script/timer approach and went with the ad block test site Test Ad Block - Toolz from 9% to 54% of blocked ads with the sailfish browser - pretty nice.

However, for AAS Fennec with ublock I get 96%…

1 Like

I get 87% with Blocky and wally3k’s ticked list :slight_smile:

1 Like

Check this part of this guide, I use these DNS on my laptop and they are doing a pretty well job:

1 Like

I get very similar results even with the strictest single list.

The developer of this tool also made this one. Not sure what the difference is, but it gives far less flattering results. I could not find any other differentiated & opensourced tools.

Using firebog.net’s meta list combined into one big hosts file I get +80% with both tools.

A slightly stricter µBlock configuration gives me 100% though, and µBlock gets a lot of its lists in AdBlock format. I will try to figure out how to best convert these to hosts format.

Anyhow, I updated my script and uploaded it to a VCS site. To be continued.

3 Likes

Using (DNS alternative ) + DNScrypt-proxy blocklist + Defender II that can be used simultaneously, I get 93% for lists updated in August.