Fix adblockplus glue code to work with recent version of the extension.
[conkeror.git] / modules / extensions / adblockplus.js
blob9b9a9d33c5fd45aaadcdd3cadf82cdfe0ea67313
1 /**
2  * (C) Copyright 2008 Jeremy Maitin-Shepard
3  *
4  * Use, modification, and distribution are subject to the terms specified in the
5  * COPYING file.
6 **/
8 interactive("adblockplus-settings",
9     "Show the Adblock Plus settings dialog.",
10     function (I) {
11         if (! ("@adblockplus.org/abp/public;1" in Cc))
12             throw interactive_error("Adblock Plus not found");
13         make_chrome_window("chrome://adblockplus/content/ui/settings.xul");
14     });
16 interactive("adblockplus-filters",
17     "Show the Adblock Plus filter settings dialog.",
18     function (I) {
19         if (! ("@adblockplus.org/abp/public;1" in Cc))
20             throw interactive_error("Adblock Plus not found");
21         make_chrome_window("chrome://adblockplus/content/ui/filters.xul");
22     });
24 interactive("adblockplus-add",
25     "Add a pattern to Adblock Plus.",
26     function (I) {
27         if (! ("@adblockplus.org/abp/public;1" in Cc))
28             throw interactive_error("Adblock Plus not found");
30         // Access the API per the instructions here:
31         // https://adblockplus.org/en/IAdblockPlus
32         var abpURL = Components.classes["@adblockplus.org/abp/public;1"]
33             .getService(Components.interfaces.nsIURI);
34         var AdblockPlus = Components.utils.import(abpURL.spec, null).AdblockPlus;
36         var element = yield read_browser_object(I);
37         var spec = load_spec(element);
38         var pattern = yield I.minibuffer.read_url(
39             $prompt = "Adblock:",
40             $initial_value = load_spec_uri_string(spec),
41             $history = "url");
42         AdblockPlus.addPatterns([load_spec_uri_string(pattern)]);
43         I.buffer.web_navigation.reload(Ci.nsIWebNavigation.LOAD_FLAGS_NONE);
44     },
45     $browser_object = browser_object_images,
46     $prompt = "Adblock");
48 provide("adblockplus");