IAdblockPlus

General notes

This interface can be used from extensions that wish to integrate with Adblock Plus. It allows among other things getting some information from Adblock Plus or adding "special" subscriptions that will be updated by another extension.

if ("@adblockplus.org/abp/public;1" in Components.classes)
{
  var abpURL = Components.classes["@adblockplus.org/abp/public;1"]
                         .getService(Components.interfaces.nsIURI);
  var AdblockPlus = Components.utils.import(abpURL.spec, null).AdblockPlus;
  alert(AdblockPlus.subscriptionCount);
}
else
{
  // Adblock Plus is not installed
}

Methods and properties


readonly PRInt32 subscriptionCount

Number of subscriptions in the list (including special subscriptions)


IAdblockPlusSubscription getSubscription ( AString id )

Retrieves a subscription by its identifier

Arguments:
id: subscription's identifier (this is subscription's URL for regular subscriptions)
Returns:
the requested subscription or null if no subscription with the given identifier exists

IAdblockPlusSubscription getSubscriptionAt ( PRInt32 index )

Retrieves a subscription by its position in the list

Arguments:
index: subscription's position in the list, zero-based
Returns:
the requested subscription or null if the index provided is invalid

wstring updateExternalSubscription ( AString id, AUTF8String title, arrayof wstring patterns )

Updates an external subscription (or creates it if no such subscription currently exists). Such a subscription will not be updated by Adblock Plus, instead the extension calling this method is responsible for updating it and removing once the subscription is no longer required.

Adblock Plus 1.3 and higher: External subscriptions will no longer be saved to disk along with other subscription, updateExternalSubscription() method needs to be called each time the browser starts up to restore the subscription. This is to prevent keeping a stale external subscription in the list if the user uninstalls the extension managing it.

Also, before Adblock Plus 1.3 this method returned a boolean indicating whether the subscription could be created. Creating a subscription can no longer fail in Adblock Plus 1.3 and higher but its identifier might be rewritten — the new identifier will be returned.

Arguments:
id: subscription's identifier (for external subscriptions this can be any string)
title: subscription title to be used if a new subscription is created. This parameter will be ignored if the subscription already exists.
patterns: list of filter patterns that the subscription should contain
Returns:
effective subscription identifier (might not be identical to the id parameter)

boolean removeExternalSubscription ( AString id )

Removes an external subscription

Arguments:
id: subscription's identifier (for external subscriptions this can be any string)
Returns:
true if the subscription has been successfully removed, false if no such subscription exists or the subscription isn't managed externally

void addPatterns ( arrayof wstring patterns )

Adds patterns to the list of user-defined filters

Version:
0.7.2.3 and higher
Arguments:
patterns: list of filter patterns to be added

void removePatterns ( arrayof wstring patterns )

Removes patterns from the list of user-defined filters

Version:
0.7.2.3 and higher
Arguments:
patterns: list of filter patterns to be removed

AString getInstalledVersion ( )

Retrieves the version of the installed Adblock Plus extension. Note that this is the version number as reported by the extension manager or InstallTrigger and it might be incorrect if the latter is used (in Mozilla Suite or SeaMonkey).

Returns:
Adblock Plus version, for example 0.7.0.1