Esempio n. 1
0
  onBeforeCreated: function(document) {
    try {
      let window = document.defaultView;
      let $ = i => document.getElementById(i);
      if (!(window instanceof Ci.nsIInterfaceRequestor)) {
        throw new Error("window is something fishy: " + window);
      }
      let winUtils = window.getInterface(Ci.nsIDOMWindowUtils);
      if (!winUtils) {
        throw new Error("No window utils");
      }
      let panels = $("PanelUI-multiView");
      if (!panels) {
        throw new Error("No panels");
      }

      let uri = Services.io.newURI("chrome://fastaddons/skin/", null, null);
      try {
        winUtils.loadSheet(uri, Ci.nsIDOMWindowUtils.AUTHOR_SHEET);
      }
      catch (ex) {
        throw new Error("Failed in inject style sheet");
      }

      let panel = document.createElement("panelview");
      panel.setAttribute("id", this.viewId);
      panel.setAttribute("flex", "1");
      panels.appendChild(panel);

      unloadWindow(window, () => {
        panels.removeChild(panel);
        try {
          winUtils.removeSheet(uri, Ci.nsIDOMWindowUtils.AUTHOR_SHEET);
        }
        catch (ex) {
          log(LOG_ERROR, "failed to unload sheet: " + uri.spec, ex);
        }
      });

      let items = document.createElement("vbox");
      items.setAttribute("class", "panel-subview-body");
      items.setAttribute("id", this.viewId + "-items");
      panel.appendChild(items);

      let footer = document.createElement("toolbarbutton");
      footer.setAttribute("label", "Show Add-ons");
      footer.setAttribute("class", "panel-subview-footer subviewbutton");
      footer.addEventListener("command", e => window.BrowserOpenAddonsMgr());
      panel.appendChild(footer);
    }
    catch (ex) {
      log(LOG_ERROR, "Failed to build view", ex);
    }
  },
Esempio n. 2
0
 gBrowser.getNotificationBox = function() {
   let rv = getNotificationBox.apply(gBrowser, arguments);
   if (rv && rv.appendNotification &&
       rv.appendNotification !== appendNotification) {
     rv._nopluginbar_appendNotification = rv.appendNotification;
     rv.appendNotification = appendNotification;
     unloadWindow(window, function() {
       rv.appendNotification = rv._nopluginbar_appendNotification;
     });
     log(LOG_DEBUG, "hijacked appendNotification");
   }
   return rv;
 };
Esempio n. 3
0
watchWindows("chrome://browser/content/browser.xul", function(window) {
  const {gBrowser} = window;
  const getNotificationBox = gBrowser.getNotificationBox;
  gBrowser.getNotificationBox = function() {
    let rv = getNotificationBox.apply(gBrowser, arguments);
    if (rv && rv.appendNotification &&
        rv.appendNotification !== appendNotification) {
      rv._nopluginbar_appendNotification = rv.appendNotification;
      rv.appendNotification = appendNotification;
      unloadWindow(window, function() {
        rv.appendNotification = rv._nopluginbar_appendNotification;
      });
      log(LOG_DEBUG, "hijacked appendNotification");
    }
    return rv;
  };
  unloadWindow(window, function() {
    gBrowser.getNotificationBox = getNotificationBox;
  });
});