Source Code

Getting the source code

The Adblock Plus source code can viewed throught the HG web interface. A local copy may be downloaded by running the following from the command line:

hg clone https://hg.adblockplus.org/adblockplus/

Similar repositories are set up for Element Hiding Helper and Diagnostics for Adblock Plus. The local copy may be reset to the state of a particular release by running the command:

hg up -r 1.0.1

(replace 1.0.1 with the tag of the required version).

Alternatively, you can also download the source code of the latest release.

The Adblock Plus source code documentation provides an overview of the add-on internals.

HG client and documentation links

Creating an Adblock Plus build

A development build may be created by entering the "adblockplus" directory (your local copy of the repository) and running the command:

python build.py build

The script will create a development build with a name in the form adblockplus-1.2.3.4+.nnnn.xpi. This file will contain the source code currently in the repository and all available locales.

Note: You need Python 2.x with Jinja2 module to create builds. To install Jinja2 in Python run this command:

easy_install Jinja2

Testing your changes

To simplify the process of testing your changes you can install Extension Auto-Installer in your browser. Assuming that Extension Auto-Installer is configured to use port 8888 (the default value), you can push your changes to this browser by running:

  python build.py autoinstall 8888

The browser will be restarted automatically if necessary.

Running unit tests

To verify your changes you can use the existing unit test suite. The unit tests are a separate extension that is installed in addition to Adblock Plus. You can either install the existing unit test builds or clone the repository and create your own build. After installing the unit tests go to chrome://adblockplustests/content/index.html to run the tests.