[Pkg-mozext-commits] [adblock-plus-element-hiding-helper] 370/483: Added Page Inspector integration (Firefox 10 and higher)

David Prévot taffit at moszumanska.debian.org
Thu Jan 22 21:41:58 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository adblock-plus-element-hiding-helper.

commit 2d34c5447c29703c9485056e3292d2d906b29342
Author: Wladimir Palant <trev at adblockplus.org>
Date:   Thu Jan 19 11:11:50 2012 +0100

    Added Page Inspector integration (Firefox 10 and higher)
---
 chrome/locale/en-US/global.properties |  4 +++
 modules/AppIntegration.jsm            | 63 +++++++++++++++++++++++++++++++++++
 2 files changed, 67 insertions(+)

diff --git a/chrome/locale/en-US/global.properties b/chrome/locale/en-US/global.properties
index b4c51b1..186e77b 100644
--- a/chrome/locale/en-US/global.properties
+++ b/chrome/locale/en-US/global.properties
@@ -30,3 +30,7 @@ command.showMenu.alternativeKey=
 
 selectelement.label=Select an element to hide
 stopselection.label=Abort element selection
+
+inspector.button.label=Hide with ABP
+inspector.button.accesskey=A
+inspector.button.tooltiptext=Create an element hiding rule to hide this element and similar ones with Adblock Plus
diff --git a/modules/AppIntegration.jsm b/modules/AppIntegration.jsm
index f9b4454..d65e037 100644
--- a/modules/AppIntegration.jsm
+++ b/modules/AppIntegration.jsm
@@ -70,6 +70,7 @@ var AppIntegration =
         if (child.nodeType == child.PROCESSING_INSTRUCTION_NODE)
           WindowObserver.overlay._processing.push(child);
       WindowObserver.startup();
+      InspectorObserver.startup();
     }.bind(this), false);
     request2.send(null);
   },
@@ -90,6 +91,7 @@ var AppIntegration =
     Prefs.shutdown();
     Aardvark.quit();
     WindowObserver.shutdown();
+    InspectorObserver.shutdown();
 
     Cu.unload("chrome://elemhidehelper-modules/content/Aardvark.jsm");
     Cu.unload("chrome://elemhidehelper-modules/content/Prefs.jsm");
@@ -208,6 +210,67 @@ var WindowObserver =
   QueryInterface: XPCOMUtils.generateQI([Ci.nsISupportsWeakReference, Ci.nsIObserver])
 };
 
+var InspectorObserver =
+{
+  initialized: false,
+
+  startup: function()
+  {
+    if (this.initialized)
+      return;
+    this.initialized = true;
+
+    Services.obs.addObserver(this, "inspector-opened", true);
+  },
+
+  shutdown: function()
+  {
+    if (!this.initialized)
+      return;
+    this.initialized = false;
+
+    Services.obs.removeObserver(this, "inspector-opened");
+  },
+
+  get inspectorButton()
+  {
+    let stringBundle = Services.strings.createBundle("chrome://elemhidehelper/locale/global.properties");
+    let result = [stringBundle.GetStringFromName("inspector.button.label"), stringBundle.GetStringFromName("inspector.button.accesskey"), stringBundle.GetStringFromName("inspector.button.tooltiptext")];
+
+    delete this.inspectorButton;
+    this.__defineGetter__("inspectorButton", function() result);
+    return this.inspectorButton;
+  },
+
+  observe: function(subject, topic, data)
+  {
+    if (topic != "inspector-opened")
+      return;
+
+    let InspectorUI = subject.wrappedJSObject;
+    let hooks = InspectorUI.chromeDoc.getElementById("abp-hooks");
+    if (!hooks || !Aardvark.canSelect(hooks.getBrowser()))
+      return;
+
+    let [label, accesskey, tooltiptext] = this.inspectorButton;
+    InspectorUI.registerTool({
+      id: "abp-elemhide",
+      label: label,
+      accesskey: accesskey,
+      tooltiptext: tooltiptext,
+      get isOpen() false,
+      show: function(selection)
+      {
+        InspectorUI.chromeWin.openDialog("chrome://elemhidehelper/content/composer.xul", "_blank",
+                                         "chrome,centerscreen,resizable,dialog=no", selection);
+        InspectorUI.closeInspectorUI();
+      }
+    });
+  },
+
+  QueryInterface: XPCOMUtils.generateQI([Ci.nsISupportsWeakReference, Ci.nsIObserver])
+};
+
 function WindowWrapper(wnd)
 {
   this.window = wnd;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/adblock-plus-element-hiding-helper.git



More information about the Pkg-mozext-commits mailing list