AdBlock Extension
Contents
New Design
Regular expressions
By default, Epiphany's AdBlock will come with a list of Perl regular expression filters -- FilterSet.G. This will be installed as /usr/share/epiphany-extensions/adblock-patterns. Any URL matching that pattern will be blocked.
But of course, there will be a few false positives. In my tests, that proportion will be very small, but it won't be 0. What's more, power users may be annoyed and want to add regular expressions of their own. The files ~/.gnome2/epiphany/extensions/data/adblock/(blacklist|whitelist) are used for these purposes.
User Interface
The #1 requirement (which already works): ads will simply be blocked with no setup required. The user will be notified by an icon on the statusbar, similar to the popup-blocker. FUTURE: the ad itself will be replaced by a proxy HTML element with a nice logo. Clicking on the logo will load the ad. Right-clicking, one would get the option to permanently allow the ad's host (automatically writing to the user's whitelist file).
The user will be able to go to View -> Advertisements -> [list of hosts], where [list of hosts] is a list of all blocked hosts, as toggles. Toggling ads on will load them immediately. Turning them back off will not change the current page (unless I decide the hacking effort is worthwhile...). spark: probably better to turn ads on individually by context-clicking them since users won't know which ads correspond to which hosts.
There will be no front-end to the blacklist or whitelist files (besides our per-host whitelist entries). However, we could listen for changes to the files and automatically reload the block lists; that would give power users the opportunity to test their regular expressions immediately.
Current Status
The blocking works, but very little UI has been written so far. There's a proof-of-concept statusbar icon which shows up when ads are blocked (and stays when you switch tabs...).
The current extension crashes on shutdown. I believe that's because of Mozilla's Bug #246092, for which Christian has written a patch.
see also #364285 (Enable adblock by default)
Concerns
I don't know how fast this will all be. But it will certainly be much faster than Firefox's, since it only compiles the regular expressions once and since it's written in C and not Javascript. In my tests, I haven't noticed any slowdowns; having a lot of entries on a whitelist may change that, though. Ideally, there would be little need for those; if the need is too great, we'll have to diverge from FilterSet.G (which is a shame, because that list is frequently updated).
Suggestions
Blocking based on image (and HTML element?) size would help, similar to the BannerBlind extension.
Making animated GIFs, Flash, and Java click to play would be a simple method that would go a long way in improving people's web experiences, as Flashblock does only for flash.
Old (obsolete) Brainstorming
Existing implementation
The epiphany-extensions CVS module has an adblock extension. Install it, and edit ~/.gnome2/epiphany/extensions/data/adblock-patterns to add some POSIX regular expression patterns. For example:
.*/ad/.*
.*/ads/.*
.*/banner/.*
.*adtech.*
.*annonce.*
.*banners.*
.*doubleclick.*
# From Slashdot
Planning
There is an obvious need for an ad-blocking extension, like Mozilla's AdBlock extension. However, that extension is not worth porting to Epiphany as-is. What do we need/want related to the Mozilla extension?
http://adblock.mozdev.org/settings.rf1.png
- We want blocking content from specific hosts -- doubleclick.net, for example
We probably want right-click on an image -> "Block content from {host}" (and possibly "Block content from {host/subdir}", etc)
- Regular expressions (POSIX regexes are dead easy to implement, and are in fact already done. Glob is easy, too, and might be a better option.)
- A dialog, "Block-able items on this page". This could be very handy. Maybe it could integrate with the page-info extension?
What does the Mozilla extension do wrong?
TONS. Impossible to list it all. Basically, it is not easy to use, despite the assertion that it is on the front page and the reviews from tons of "power users". The prefs window has tons of meaningless options ("Obj-tabs") and the thing takes more than five minutes to set up for a new user.
The biggest problem, though, is that it takes effort! I've used Bayesian filtering on Evolution, and it was painless (with zero false positives, ever). Adblock is, in comparison, a nightmare. When you first install it, for example, it does nothing. Enabling/disabling the filter only applies to the next page load. Disabling filters is nontrivial.
On the other hand, people love Adblock. They have no idea how much better things could be.
So let's go back to basics: what do we want?
- We want to block IFRAMEs, IMGs, EMBEDs, OBJECTs and As which contain advertisements.
- We want to easily be able to undo our ad-blocking (like the popup blocker). This could possibly be on a per-site basis (i.e. I like example.com, don't show me ads from that site)
We want to avoid at all costs somebody saying, "There's supposed to be an image there but it didn't load! My browser is broken."
What can we use?
userContent.css rules which work okay. They are reported to "stop about 99% of the ads on the Internet". That means 1% come through, and advertisers obviously will change their ways to make that 1% bigger.
EphyContentPolicy. The check-content signal lets us deny loading based on (guessed) MIME type, URL, referrer. This is better than the stylesheet because it doesn't even issue the HTTP request.
EphyPermissionsManager. Just as with popup windows and cookies, images can be blocked on a per-site basis. (Interesting idea: should we block cookies at the same time as blocking images?)
- DOM tree walking. We could find images of popular banner sizes (600x120, 730x92, etc) and block their hosts automatically.
Existing AdBlock rulesets, refined from long-time adblock users. I worry about their reliability, though.
We could also maintain our own ad-blocking list. SpamAssassin maintains a list of regular expressions, and it Just Works with Evolution.
What do we have that works well?
The popup blocker is simple and effective. View -> Content From -> {list of host websites, as toggle actions}?
Maybe even "View -> Ad-like content" on a per-site basis, exactly like popup blocker. This may suck for ad-intensive sites which also use a banner for regular use
Keep in mind, the popup blocker has very few cases in which you'd want it disabled. Ad-blocking is unlikely to be as reliably correct.
Comments
Adblock is dead. Adblock Plus is what's used on Firefox nowadays. It works two ways: content policies and custom stylesheets. The filter syntax has been greatly expanded from Adblock, all of which is documented on the website. ABP prefers simple syntax over regular expressions because they are much faster the way they are implemented in ABP. There is a regularly updated list for English sites called EasyList. More subscriptions for different languages are avaiable at http://adblockplus.org/en/subscriptions
