Add a pattern to Adblock Plus based on a target. The target can be
selected and then edited. The default target type is "images", as they
are the most common obnoxious content.
---
> Fixed. Noticed another bug along the way, so it's onward and upward. :)
Thanks very much for that.
Some possibly questionable decisions in this patch:
- I made the whole thing an interactive definition, rather than
defining a separate function; I think this is correct because the
whole point of this function is to provide a UI.
- I put the default_browser_object_classes change in the extension
support file, rather than in element.js.
- I used the "url" history list. Possibly it should be separate.
- adblockplus_service.normalizeFilter() doesn't seem to be
necessary, but i don't really know what it's for.
regards, David
modules/extensions/adblockplus.js | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/modules/extensions/adblockplus.js
b/modules/extensions/adblockplus.js
index de60997..a917e88 100644
--- a/modules/extensions/adblockplus.js
+++ b/modules/extensions/adblockplus.js
@@ -22,3 +22,23 @@ function adblockplus_settings(buffer, uri_string) {
}
interactive("adblockplus-settings", "Show the Adblock Plus settings dialog.",
function (I) { adblockplus_settings(I.buffer); });
+
+default_browser_object_classes.adblock = "images";
+
+interactive("adblockplus-add", "Add a pattern to Adblock Plus.",
+ function (I) {
+ var element = yield I.read_browser_object("adblock", "Adblock");
+
+ var spec = element_get_load_spec(element);
+ if (spec == null)
+ throw interactive_error("Element has no associated URI");
+
+ var pattern = yield I.minibuffer.read_url(
+ $prompt = "Adblock:",
+ $initial_value = load_spec_uri_string(spec),
+ $history = "url");
+
+ adblockplus_service.addPatterns([pattern]);
+
+ I.buffer.web_navigation.reload(Ci.nsIWebNavigation.LOAD_FLAGS_NONE);
+});
--
1.6.0.2.304.gc76d.dirty
--
IMPORTANT: This email remains the property of the Australian Defence
Organisation and is subject to the jurisdiction of section 70 of the
CRIMES ACT 1914. If you have received this email in error, you are
requested to contact the sender and delete the email.
_______________________________________________
Conkeror mailing list
[email protected]
https://www.mozdev.org/mailman/listinfo/conkeror