From 75aa17f1694fc2ae22f1e85bcf5d15ebbdf257f0 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sun, 11 Dec 2022 18:38:27 -0700 Subject: [PATCH] Fix running function passed to Zotero.openInViewer() This fixes plugin removal in the Add-ons window. Broken by b8966f7878 --- chrome/content/zotero/xpcom/zotero.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index 1e2cf9a75f..1986a6a833 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -1127,8 +1127,12 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js"); let browser let func = function () { win.removeEventListener("load", func); - browser = win.document.documentElement.getElementsByTagName('browser')[0]; - browser.addEventListener("pageshow", innerFunc); + // is created in basicViewer.js in a window load event, so we have to + // wait for that + setTimeout(() => { + browser = win.document.documentElement.getElementsByTagName('browser')[0]; + browser.addEventListener("pageshow", innerFunc); + }); }; let innerFunc = function () { browser.removeEventListener("pageshow", innerFunc);