Hide unsigned add-on warning in Standalone

There's no need for Zotero Standalone add-ons to be signed by Mozilla.

Currently only hides when the Extensions pane is first loaded, so if the user
switches to Appearance or Plugins and switches back, the warning reappears
This commit is contained in:
Dan Stillman 2016-07-23 16:21:43 -04:00
parent 01aec4134c
commit 254da12e12
2 changed files with 48 additions and 4 deletions

View file

@ -106,18 +106,62 @@ const ZoteroStandalone = new function() {
}
/**
* Opens a URL in the basic viewer
* Opens a URL in the basic viewer, and optionally run a callback on load
*
* @param {String} uri
* @param {Function} [onLoad] - Function to run once URI is loaded; passed the loaded document
*/
this.openInViewer = function(uri) {
this.openInViewer = function(uri, onLoad) {
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
var win = wm.getMostRecentWindow("zotero:basicViewer");
if(win) {
win.loadURI(uri);
} else {
window.openDialog("chrome://zotero/content/standalone/basicViewer.xul",
win = window.openDialog("chrome://zotero/content/standalone/basicViewer.xul",
"basicViewer", "chrome,resizable,centerscreen,menubar,scrollbars", uri);
}
if (onLoad) {
let browser
let func = function () {
win.removeEventListener("load", func);
browser = win.document.documentElement.getElementsByTagName('browser')[0];
browser.addEventListener("pageshow", innerFunc);
};
let innerFunc = function () {
browser.removeEventListener("pageshow", innerFunc);
onLoad(browser.contentDocument);
};
win.addEventListener("load", func);
}
}
this.updateAddonsPane = function (doc) {
// Hide unsigned add-on verification warnings
//
// This only works for the initial load of the window. If the user switches to Appearance
// or Plugins and then back to Extensions, the warnings will appear again. A better way to
// disable this might be discoverable by studying
// https://dxr.mozilla.org/mozilla-central/source/toolkit/mozapps/extensions/content/extensions.js
var addonList = doc.getElementById('addon-list');
setTimeout(function () {
for (let i = 0; i < addonList.itemCount; i++) {
let richListItem = addonList.getItemAtIndex(i);
let container = doc.getAnonymousElementByAttribute(
richListItem, 'anonid', 'warning-container'
);
if (container) {
let link = doc.getAnonymousElementByAttribute(
richListItem, 'anonid', 'warning-link'
);
if (link && link.href.indexOf('unsigned-addons') != -1) {
richListItem.removeAttribute('notification');
container.hidden = true;
}
}
}
});
}
/**

View file

@ -168,7 +168,7 @@
command="cmd_zotero_rtfScan"/>
<menuseparator/>
<menuitem id="menu_addons" label="&addons.label;"
oncommand="ZoteroStandalone.openInViewer('chrome://mozapps/content/extensions/extensions.xul')"/>
oncommand="ZoteroStandalone.openInViewer('chrome://mozapps/content/extensions/extensions.xul', ZoteroStandalone.updateAddonsPane)"/>
</menupopup>
</menu>