From bdd2fb9a5361064c8efbeaf9177c9899d2f355fc Mon Sep 17 00:00:00 2001 From: JustOff Date: Wed, 13 Dec 2017 16:25:28 +0200 Subject: [PATCH] Add CAA to Tools menu --- bootstrap.js | 25 +++++++++++++++++++++++++ skin/button.css | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/bootstrap.js b/bootstrap.js index 10183ab..41dde3e 100644 --- a/bootstrap.js +++ b/bootstrap.js @@ -114,14 +114,36 @@ let button = { } }; +let menuitem = { + meta : { + id : "ca-archive-menu", + label : "Classic Add-ons Archive", + class : "menuitem-iconic" + }, + install : function (w) { + let doc = w.document; + let m = doc.createElement("menuitem"); + for (let a in this.meta) { + m.setAttribute(a, this.meta[a]); + } + m.style.listStyleImage = 'url("chrome://ca-archive/skin/button.png")'; + + let menu = $(doc, "menu_ToolsPopup"); + menu.insertBefore(m, null); + return m; + } +}; + let caaIn = function (w) { let b = button.install(w); + let m = menuitem.install(w); return { init : function () { w.addEventListener("customizationchange", button.onCustomize, false); w.addEventListener("aftercustomization", button.afterCustomize, false); b.addEventListener("command", this.run, false); + m.addEventListener("command", this.run, false); }, done : function () { w.removeEventListener("customizationchange", button.onCustomize, false); @@ -129,6 +151,9 @@ let caaIn = function (w) { b.removeEventListener("command", this.run, false); b.parentNode.removeChild(b); b = null; + m.removeEventListener("command", this.run, false); + m.parentNode.removeChild(m); + m = null; }, run : function () { if (Services.ppmm.childCount > 1) { diff --git a/skin/button.css b/skin/button.css index bfd1023..d4f0909 100644 --- a/skin/button.css +++ b/skin/button.css @@ -8,7 +8,7 @@ -moz-box-orient: horizontal !important; } - #ca-archive-button { + #ca-archive-button, #ca-archive-menu .menu-iconic-left { -moz-image-region: rect(0, 48px, 16px, 32px); }