Thomas Fischer's Weblog

Life, Linux, LaTeX

Automatic AdBlock filter list updates in Konqueror

with 4 comments

As a KDE user, Konqueror is my favorite browser. It offers smooth integration into KDE, both in looks and features (e.g. using the Okular part to view PDFs). Its rendering engine is so good that it was forked into WebKit used in Apple’s Safari and Qt. One aspect Konqueror lacks in comparison to Firefox, though, is the support of plugins/addons of all kinds to add more features to the browser. There is a set of security and privacy enhancing plugins for Firefox I use myself and recommend to others. One of them is AdBlock Plus which uses a well-maintained list of URLs to block if you want to experience the net with less annoyance.

On the other side, Konqueror has a similar adblocking functionality built-in since KDE 3.5 (late 2005). In the configuration dialog, users can add fragments or regular expressions of URLs to be blocked. Maintaining such a list yourself is quite cumbersome, especially if you have accounts on several computers. At least since March 2007 there has been a feature request in KDE’s bug tracking system to add an automatic updater to Konqueror’s ad-filtering.

Last weekend, I started to scratch the itch and implemented an automatic filter list updater. Luckily, the internal format of AdBlock entries in Konqueror matches the one use by AdBlock Plus, except that some advanced features are not (yet) supported. Based on the then-current KDE 4.2.4 code I made changes to both kdelibs and kdebase. The former one contains the KHTML component including the actual filter, the latter contains the code for Konqueror’s settings GUI.

The changes I made to kdelibs work as follows: Read the khtmlrc configuration file to get a list of filter files following the format used by AdBlock Plus. My example configuration file contains several lists from easylist.adblock.org. The filter list files are downloaded and cached if no local copy is available or if it is outdated. Each filter list file is loaded and added to Konqueror’s current filter list each time the browser is started. The user-configured filter list is not modified, as the changes occur in memory only.

If you edit your khtmlrc manually to add new filter lists, this works already fine without GUI. For a better usability experience, I modified Konqueror’s settings dialog so that users can select from a list of preconfigured filter lists (currently, all lists from EasyList) which to actually use. Additionally, the time interval to refresh the lists can be configured.

Manual filter in Konqueror's AdBlockAutomatic filter in Konqueror's AdBlock

I refrained from adding an option to add, modify or delete list entries in the GUI. This is simply for two reasons: (1) Users may tend to enter filter lists that do not follow the format (e.g. from other adblocking filter sites) and (2) the list of available filter lists does not change that often that it cannot be changed in the next monthly update of KDE. If users are eager to add more lists not officially approved, they can still edit their configuration files manually.

All patches and an example configuration file are available from bug report 143495 in KDE’s bug tracking system. If you have constructive suggestions, please add you comments to the bug report (do not post comments in this blog, that won’t help). To support the patch in getting approved and added to the official code base, vote for the bug (login required).

Update (20091201): I posted the patches on KDE’s Review Board a few days ago and got a review from David Faure. There are some minor issues to change and fix, but his overall comment was “Nice (but obviously not for 4.4 due to the feature freeze, it will have to be for 4.5)” πŸ™‚

Update (20100812): My AdBlock extension has become part of KDE 4.5 πŸ™‚ Check out this screen shot:AdBlock filter list in KDE 4.5

Advertisements

Written by Thomas Fischer

August 5, 2009 at 22:08

Posted in KDE, Linux

Tagged with , ,

4 Responses

Subscribe to comments with RSS.

  1. Unfortunately, these patches do not work with kdelibs-4.3.1. I added all needed string manually, but the compile fails. 😦

    Satarsa

    September 4, 2009 at 18:46

  2. Oh, I could build kdelibs and konqueror of kde-4.3.1, it works greate, thank you. It would be nice to add this patches to the official kde.

    Satarsa

    September 12, 2009 at 10:34

  3. I updated the patches for KDE 4.3.1. Basically, only line numbers changed. If you want to have this patch added to officially to KDE, please register at bugs.kde.org and vote for the bugreport.

    Thomas Fischer

    September 25, 2009 at 17:16

  4. Thanks for one’s marvelous posting! I actually enjoyed reading it,
    you happen to be a great author. I will always
    bookmark your blog and definitely will come back in the future.
    I want to encourage that you continue your great posts, have a nice holiday weekend!

    lasertest

    October 25, 2015 at 14:05


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: