Block ads on Sailfish 4.4

Defender doesn’t work anymore even with SailJail disabled. Is there another way to block ads on SailfishOS 4.4?

Thank you :slight_smile:

3 Likes

You can manually update your /etc/hosts file from here, however the current hosts file has not been updated for almost a year now.

ps make sure you keep a copy of the original /etc/hosts file.

6 Likes

I use the Steven Black hosts blocklist project on linux desktops and on my pinephone running pmos. I haven’t tried it on sailfish, since defender exists – or existed, but I’d think that all the dependencies would be installable.

2 Likes

Modifying /etc/hosts from winhelp2000 served me for many years. AFAIR the maintainer halted that project for health reasons. As @robthebold I switched to StevenBlack’s project.

Unfortunately this doesn’t work for AlienDalvik / Android apps, even if you copy or map them to the LXC container, any hints to filter ads on Android?

2 Likes

This worked brilliantly for me up until 4.3 (didn’t try 4.4 yet).
Just follow comments for the setup, but it should be fairly easy.

hosts-adblock

Edit: it doesn’t work on SFOS 4.4
Even manually copying hosts file doesn’t seem to work for me. What a bummer.

Did you try hosty?
It works fine for me on sfos 4.4, and you have instructions about how to install it on sailfishos

3 Likes

I wish if I could use ublock/adblock plus in the browser!

hosts based adblocking nowadays does not worth too much…

4 Likes

Could you perhaps share a step-by-step on how to use hosty for noobs?

1 Like

Yes, of course, you must follow next steps to INSTALL hosty:

  1. Enable “Developer Mode” from Settings. Terminal will be installed in your phone
  2. Open Terminal and run next commands.
    devel-su pkcon install p7zip-full gawk gzip nano
    devel-su pkcon install gnu-bash #NOTE:This action will remove busybox-symlinks-bash package under your responsibility
    devel-su ln -s /usr/bin/gpg2 /usr/bin/gpg
  3. Install cronie or vixie-cron from openrepos.net
  4. Install sudo from Terminal:
    devel-su pkcon install sudo
  5. Edit “sudoers” using “nano” and add “defaultuser” to properly use of hosty:
    devel-su nano /etc/sudoers
    Adding at the end of the file:
    defaultuser ALL=(ALL) ALL
  6. Just run:
    curl -L git.io/hosty | sh
  7. During installation hosty will ask if you want to automatically run hosty from time to time to update your hosts file with the latest list of domains.
    We answer the following questions:
    Do you want to always run the latest version of hosty? Y
    Do you want to automatically update your hosts file with latest ads list? n
  8. Once hosty ends its installation, just run again:
    curl -L git.io/hosty | sh

To RUN hosty, just run sudo hosty from Terminal. You probably want to run it periodically to update your hosts file with latest domains list or you can use sailcron for that.

NOTE: I use hosty since sfos 4.2, but I remember that I had to install and unistall defender II to get working properly. I’m on sfos 4.4

11 Likes

That’s amazing! Thank you so much! I’ll try to do it ASAP.

Edit: it’s working like a charm after I removed the hosts-AdBlock app and rebooted the device

Did you install/uninstall defenderII?

1 Like

I removed it and it’s working as advertised. Amazing! Thank you so much!

1 Like

I’ll be the “party pooper” and say that the above method described by carmen -while it works- isn’t the most user friendly way of doing something. :confused:

We need ublock.

1 Like

Not only that. So much heated security and privacy discussions e.g. like in the other thread about SFOS 4.4 and AML and then we let the unsecure practice of the “curl <random_url> | sh” still live.

3 Likes

Hi. Thanks for this detailled info…
Does it require anything special with the OS Updates ??

What about an inbuild Solution for the SailfishOS-Browser?

The Browser using the ESR78-Firefox-Engine, so there is no way to add Plugins like Adblock?

1 Like

I found out why Defender doesn’t work anymore. First, database where cookies are stored is now locked when the browser is running. You must close the browser for Defender to work.

Second issue, database’s schema has changed. And a column doesn’t exist anymore. I already found a solution, but I need more time to provide a PR.

If someone with python knowledge has time: here is the repository : https://github.com/peterleinchen/harbour-defender

1 Like

No, it works for me since sfos 4.2, and never stopped working in every update

You might want to contact the maintainer (@peterleinchen) of the project about this issue.

If I understand well how defender works, it downloads hosts files from the selected ones, and then process all entries and add them to SFOS host file.
On first update it’s quite fast, but on subsequent updates, it takes a very, very long time because, it seems, it checks if the entry already exists.

Wouldn’t be a good idea to write a new system adbocker, maybe in C++ or QML, with a faster efficient update mechanism ? I can try and help, though the first step is to properly define the need block ads, updates, etc.) and architecture of the software.

1 Like