Click here to Skip to main content
12,299,837 members (56,345 online)
Click here to Skip to main content
Add your own
alternative version


41 bookmarked

Internet Explorer AdBlock

, 17 Jan 2008 GPL3
Rate this:
Please Sign up or sign in to vote.
Internet Explorer AdBlock Add-on



When reading all over the Internet, there is a great advertisement blocker for FireFox (Adblock Plus). However, where is the one for Internet Explorer?

After "years" of searching for the right Internet Explorer Add-in, I decided to do something good with the time I was just wondering what to do next. So, the idea for Internet Explorer AdBlock was born. Now I only had to finish it, but that isn't the hardest part, right?


Before we begin this article, there are some requirements to meet if you want to compile the source:

Using the Code

First, I will briefly describe some problems I encountered when implementing the Internet Explorer Add-on part of Internet Explorer AdBlock. Then, I will provide some information about the Document Object Model (DOM) which you can use inside the Add-on to loop through the websites.

Internet Explorer Add-on

The first time I had to write an Internet Explorer (or for example Windows Media Player) Add-on, it was hard for me to get a grip on the way things work. For example, where to use the Browser Helper Object (BHO). And what about the user interface (the toolbar)? Can it be integrated into the BHO, or does it need to be implemented in a separate class?

This article about BHO explains what a BHO object is and how to start a BHO project.

I tried to implement the toolbar and the BHO into the same class (object), but that seemed impossible. The reason is that a BHO runs in the background of Internet Explorer, and is enabled via the Add-on settings of Internet Explorer.

The toolbar is a control that can be enabled via the toolbar region itself. However, I wanted the AdBlock to keep blocking advertisements, even if the user decided to hide the toolbar (because once you set the settings correctly, you can hide the blocker and forget about it).

Document Object Model (DOM)

To find all information about DOM, please visit the official website. I will use this section to briefly describe how to use DOM inside the Internet Explorer Add-On.

It is possible to retrieve the current webpage (for Internet Explorer 7: in the current tab) the user is visiting. The webpage is an object of the IHTMLDocument2 Interface. The interface allows any developer to examine and modify the HTML elements inside the document (the webpage).

Internet Explorer AdBlock uses the following main elements of the DOM to block advertisements:

  • Applets
  • Embeds
  • Frames (webpage inside a webpage, which is a new IHTMLDocument2 Interface)
  • Images
  • Scripts
  • Stylesheets

Performance Problems

One of the main problems of an Internet Explorer Add-on is that it is only possible to get the website after the page is fully loaded. This means that it is impossible to save bandwidth by not downloading any images. When frames are downloaded, and the frame should be fully blocked, it can be blocked thanks to the OnBeforeNavigate2 function of the DWebBrowserEvents2 Interface.

This point makes it really hard to implement an AdBlock Add-on since the advertisements can be blocked after they are loaded. So, simply said, the user has to download and view the advertisements and then wait for the Add-on to remove and hide them again.

One of the things I tried to improve performance was to implement a cache mechanism. The cache keeps track of all elements handled in a webpage and the amount of times the elements were handled. This way, it is possible to loop through a much smaller array (the cache) for frequently visited websites or elements. But, when an element is not listed in the cache, the add-on first loops through the cache and then loops through the complete black- and whitelist.

Future of Internet Explorer AdBlock

The source in this package is not fully optimized. To be more precise, the reason I decided to release the source to the open-source community is because I couldn't make the source perform much better than it does at the moment. Maybe a smart guy out there (read: you) can optimize it and release this to the public, so Internet Explorer users will finally have some tool to block the irritating advertisements on the Internet.

One of the ideas I had to improve performance (or usefulness of the Add-on) was to modify the stylesheets of the websites instead of looping through the websites. The idea is to download all stylesheets to a cache directory and modify them according to the blocking information provided by the user or any block-list Internet Explorer AdBlock synchronizes with. Then, you can smartly cache frequently visited websites and block standard advertisements without even using any processing power (except for changing the remote CSS URL to a local cached one via DOM).


  • 2008-01-18: Initial article


This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


About the Author

Geert van Horrik
Software Developer CatenaLogic
Netherlands Netherlands
I am Geert van Horrik, and I have studied Computer Science in the Netherlands.

I love to write software using .NET (especially the combination of WPF and C#). I am also the lead developer of Catel, an open-source application development framework for WPF, Silverlight, WP7 and WinRT with the focus on MVVM.

I have my own company since January 1st 2007, called CatenaLogic. This company develops commercial and non-commercial software.

To download (or buy) applications I have written, visit my website:

You may also be interested in...

Comments and Discussions

GeneralSomethings wrong with included libs Pin
KarstenK15-Oct-08 0:33
memberKarstenK15-Oct-08 0:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.160525.2 | Last Updated 17 Jan 2008
Article Copyright 2008 by Geert van Horrik
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid