Further adapt debian webjumps as suggested by John J. Foerch
[conkeror.git] / modules / extensions / adblockplus.js
blobaffbe533b0464821d53ae425bf955cb1d296f992
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 in_module(null);
10 require("extension.js");
12 if (!extension_is_enabled("{d10d0bf8-f5b5-c8b4-a8b2-2b9879e08c5d}"))
13     throw skip_module_load;
16 var adblockplus_service = Cc["@mozilla.org/adblockplus;1"]
17     .createInstance().wrappedJSObject;
20 function adblockplus_settings (buffer, uri_string) {
21     var frame = null;
22     if (buffer)
23         frame = buffer.top_frame;
24     adblockplus_service.openSettingsDialog(frame, uri_string);
26 interactive("adblockplus-settings",
27     "Show the Adblock Plus settings dialog.",
28     function (I) { adblockplus_settings(I.buffer); });
31 interactive("adblockplus-add",
32     "Add a pattern to Adblock Plus.",
33     function (I) {
34         var element = yield read_browser_object(I);
35         var spec = load_spec(element);
36         var pattern = yield I.minibuffer.read_url(
37             $prompt = "Adblock:",
38             $initial_value = load_spec_uri_string(spec),
39             $history = "url");
40         adblockplus_service.addPatterns([load_spec_uri_string(pattern)]);
41         I.buffer.web_navigation.reload(Ci.nsIWebNavigation.LOAD_FLAGS_NONE);
42     },
43     $browser_object = browser_object_images,
44     $prompt = "Adblock");
46 provide("adblockplus");