velazcod / Tinfoil-Facebook

For those users that require a Tinfoil Hat when logging in to Facebook. It creates a sandbox for facebook's mobile site.
249 stars 62 forks source link

Integrated Ad Blocker #29

Open Nutomic opened 9 years ago

Nutomic commented 9 years ago

Not sure how feasible this is, but it would be nice if ads would be blocked automatically.

averageapps commented 9 years ago

This is technically possible by running some Javascript code that removes the ads after/while loading pages.

There are some approaches on the XDA thread http://forum.xda-developers.com/showthread.php?t=1328440&page=2

But none of them got implemented in the main app, and I think it would be risky to do so, because Google often removes Apps with ad blocking functionality from the Play Store.

Maybe there is a way around that issue: We could add a feature in Tinfoil that executes arbitrary user-definable Javascript code on all page loads, where you can for example specify some ad-blocking code. This would work, is easy to implement and I think it has a higher survival chance on the Play Store, but this would be a very ugly and potentially dangerous feature that will confuse many users. Are there any better ideas?

velazcod commented 9 years ago

It's been brought up many times, but I wouldn't implement it directly, because it would be against the Google Play Stores' TOS, see here: http://arstechnica.com/gadgets/2013/03/google-evicts-ad-blocking-software-from-google-play-store/

I'm sure Facebook won't like it either, and they could potentially try to report it to Google to get it removed as well.

As for your idea @averageapps, it's not bad, but yes, there is security to keep in mind, and yes, I agree it would be ugly as well.

I don't have other ideas at the moment but I'll think about it and keep this open for now.

Nutomic commented 9 years ago

If the problem is just Google, it could be enabled only in the F-Droid/Github version?

Foggalong commented 9 years ago

@Nutomic If you're using F-droid and are that bothered about ads, why not just install one of their specific adblockers?

averageapps commented 9 years ago

@Foggalong No general ad blockers for Android that I know of can block facebook ads. (I think this is is because all (?) ad blockers work by blocking whole domains / subdomains im the /etc/hosts file, which is not fine-grained enough).

In this case, ads should be blocked by manipulating page content of already loaded pages instead of domain blacklisting.

averageapps commented 9 years ago

(Maybe it works with Adblock Plus, haven't tried it yet, but it seems to need a persistent background service, which is less than optimal).

Foggalong commented 9 years ago

I use AdAway from Fdroid and have never had any problems since, in Tinfoil or elsewhere

averageapps commented 9 years ago

I use AdAway too with all standard hosts sources plus one additional source, and facebook ads appear nonetheless.

If this wasn't clear: With ads I mean the "suggested post" entries in the news feed.

If you don't see them, I would be really interested in the content of your /etc/hosts !

velazcod commented 9 years ago

If someone is willing to work on it and make sure it's in a place where it can be enabled/disabled programmatically I'd take a look. Otherwise I'd have to pick this up and do it at some other point.

I'm ok with it being in the code but I'd need to make sure it's enabled by default (so that FDroid builds have it, or has the option to enable it), and make a custom flavor gradle config for Google Play Store builds with it disabled (and no option).

Foggalong commented 9 years ago

Not change the hosts file, sorry :( Just the standard one

olivierlemoal commented 9 years ago

I made a fork to add a custom CSS functionality to Tinfoil Facebook (625cdc69812120023042fa0c92a6e68bb2546aed). With a simple custom CSS such as :

article[data-xt-vimp], li.apm.abt{display: none;}

I can now remove some annoying messages (suggested stories and "Download Facebook Messenger"). I'm not an Android developer so a code review would be appreciated ! :smiley:

olbrew commented 9 years ago

@olivierlemoal that is a really cool idea. I'm not an Android dev so I can't check your code unfortunately. Try a pull-request and then @velazcod can decide if it's good. Optimally this would come with some prefilled CSS for (un)popular sections and options to selectively enable them in advanced settings.