Block ads on Sailfish 4.4

Hosty looks promising, I like the idea that the functionality is provided by a shell script, rather than a full-featured app.
But it seems I’m doing something wrong. When running hosty, I get multiple warnings originating from gawk, complaining about the -i inplace extension used in the extractDomains() funktion. It seems the gawk version installed cannot handle -i inplace? Gawk version is GNU Awk 3.1.5.
However, a modified hosts file is generated and installed.

Currently I’m using privoxy for adblocking, only the adblock2privoxy script was not as easy to setup.

Please just hint at the solution and I’ll go look at making a PR …

1 Like

They are in the issues :wink:

Ah, sorry, to many projects, too repos, too many tickets :slight_smile:

1 Like

Yep, I get warnings about gawk too when I run hosty

Why check? Wouldn’t it be easier to rewrite the entire file with new and updated content?

I guess it’s to prevent removing user or OS specific entries in the host file, and to avoid duplicates.

1 Like

I know many people are wary of DNS changing, but I have used Keweon for years on SF and Android, and seems solid to me. It’s been around for a long time, and is trusted. Filtering is good, support is good. Just install cert and change resolv.conf…

1 Like

Can we help here somehow?

Always! and thanks for asking! The biggest problem is communication and organization. The latter is dependent on priorities. I have to give some thought to how to organize. Some previous help I managed badly and the progress that was made reverted which lead to the insight that I need more ‘process’.

But in short, bug / issue related work:

Those are two larger bits.

1 Like

I had problems with peterleinchen’s defender, too.

And no disrespect, but hosty seems way too complex for such a simple task.

In the end I just created a systemd timer & service to curl Steven Black’s host file. Instructions. And thanks to the hosty developer for providing a tip on how to make /etc/hosts available for Android apps, too.

Problem: it seems a full reboot is required before sailfish-browser reads the new /etc/hosts. Any ideas?

3 Likes

Well, reboot will not blow the phone out of your hand. :wink:

1 Like

I tried your script, but I am getting an error message:
line 8: syntax error near unexpected token newline' line 8: curl --retry 20 --retry-all-errors --retry-connrefused --retry-delay 5 “$url” | grep ‘^0.0.0.0’ > ’
I understand that the problem is with the output redirection operator, >, but I am not sure why it doesn’t work on the phone as the same code runs fine on the computer. Do you have any suggestions what could be causing it on SFOS 4.4?

1 Like

Thanks for the nice instructions. One thought: /home/nemo/ might better be stated as ~ since some users will have /home/defaultuser and no nemo user?

1 Like

Yes. I only noticed this after writing the article. Thanks for the tip; I made some minor edits to the article.

What remains is my bad habit to have files under $HOME executed by root services, so the Exec path in the systemd service has to remain absolute.

But of course all this is just a suggestion for how to implement something yourself.

1 Like

I suspect a copy-paste error because in my article the line does not end at “>”.

2 Likes

Bummer. I should have spotted it that the rest of the line was moved to new line. Thanks for the hint. Works great now.

So does Defender now works again out-of-the-box?

I would like specially to block all google-ads

1 Like

No, you have to update the script /usr/share/harbour-defender/qml/python/defender.py. I replaced baseDomain with host on line 124, 126, 147, 155, 157, 165 and 233.

You need to close the browser before starting Defender. That’s because the DB get locked by the browser when it’s open.

1 Like