Skip to content

Instantly share code, notes, and snippets.

@philipn
Created November 2, 2010 00:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philipn/659122 to your computer and use it in GitHub Desktop.
Save philipn/659122 to your computer and use it in GitHub Desktop.
diff --git a/addart/components/addart.js b/addart/components/addart.js
index 6e1a596..fe5563d 100755
--- a/addart/components/addart.js
+++ b/addart/components/addart.js
@@ -106,11 +106,23 @@ org.eyebeam.addArt.component = {
init: function() {
// Retrieve ABP component
var abp = null;
- try {
- abp = Components.classes["@mozilla.org/adblockplus;1"].createInstance();
- if (abp && !("policy" in abp))
- abp = abp.wrappedJSObject; // Unwrap ABP component
- } catch(e) {}
+ if ("@adblockplus.org/abp/public;1" in Components.classes)
+ {
+ // Adblock Plus 1.3 or higher
+ var abpURL = Components.classes["@adblockplus.org/abp/public;1"]
+ .getService(Components.interfaces.nsIURI);
+ Components.utils.import(abpURL.spec);
+ }
+ else if ("@mozilla.org/adblockplus;1" in Components.classes)
+ {
+ // Adblock Plus 1.2.x or below
+ abp = Components.classes["@mozilla.org/adblockplus;1"]
+ .createInstance().wrappedJSObject;
+ }
+ else
+ {
+ // Adblock Plus is not installed
+ }
if (!abp)
return;
@@ -248,4 +260,4 @@ org.eyebeam.addArt.component = {
throw Components.results.NS_ERROR_NO_INTERFACE;
}
-};
\ No newline at end of file
+};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment