diff --git a/README.MD b/README.MD index e8a9c6e..2d2c9f8 100644 --- a/README.MD +++ b/README.MD @@ -1,11 +1,14 @@ -# Zotero PDF Background Plugin +# Zotero PDF Background Plugin 2.0 -![](example1.png)![](example2.png)![](example3.png) +![](example1.jpg)![](example2.jpg)![](example3.jpg) Install by downloading the [latest version](https://github.com/q77190858/zotero-pdf-background/releases/latest) ## Feature +* **Now Support Zotero7!** +* **Adapted to System Dark Mode!** +* **Adapted to Split View Mode!** * a multi pdf background to care your eyes * a button like a eye on the middle toolbar to switch different background mode @@ -15,25 +18,21 @@ Install by downloading the [latest version](https://github.com/q77190858/zotero- ## Install -- Download zotero-pdf-backgroundv0.0.2.zip +- Download zotero-pdf-backgroundv2.0.zip - Open Zotero->tools->plugins->click setting icon on right top->Install Addon from file... -- Select zotero-pdf-backgroundv0.0.2.zip file +- Select zotero-pdf-backgroundv2.0.zip file - Restart Zotero ## Build Development Environment follow these steps to build a zotero debug environment -- [ ] Download Firefox 60 (I use a portable edition) - [ ] Git clone -- [ ] Download and launch [zotero dev edition](https://www.zotero.org/support/dev_builds) with --debugger -- [ ] Launch Firefox 60 -- [ ] In Firefox, go to devtools, go to settings, click *'Enable browser chrome and add-on debugging toolboxes'* and *'Enable remote debugging'*. -- [ ] In Zotero, go to setting, advanced, config editor, look up "devtools" and set true on "devtools.debugger.remote-enabled" and set "devtools.debugger.remote-port" 6100 -- [ ] In Firefox, click the hamburger menu in the top right -> web developer -> Connect... -- [ ] Enter localhost:6100 -- [ ] Connect -- [ ] Click "Inspect Main Process" +- [ ] Download and launch [zotero dev edition](https://www.zotero.org/support/dev_builds) with -ZoteroDebugText -jsdebugger +- [ ] Launch zotero dev edition +- [ ] In zotero dev edition, a independent devtools would be started. +- [ ] A MessageBOX will ask: "An incoming request to permit remote debugging connection was detected. A remote client can take complete control over your browser!" Click "OK" to allow connection. +- [ ] To run plugin from source code, see official [setting_up_a_plugin_development_environment](https://www.zotero.org/support/dev/client_coding/plugin_development#setting_up_a_plugin_development_environment) ## Thanks -This plugin's framework is based on [zotero-night](https://github.com/tefkah/zotero-night) \ No newline at end of file +This plugin's framework is based on [official sample plugin make-it-red](https://github.com/zotero/make-it-red) \ No newline at end of file diff --git a/bootstrap.js b/bootstrap.js new file mode 100644 index 0000000..fc80bac --- /dev/null +++ b/bootstrap.js @@ -0,0 +1,42 @@ +var PDFBackground; + +function log(msg) { + Zotero.debug("zotero-pdf-bakcground: " + msg); +} + +function install() { + log("plugin Installed"); +} + +async function startup({ id, version, rootURI }) { + log("plugin start up"); + + Zotero.PreferencePanes.register({ + pluginID: 'zotero-pdf-bakcground@example.com', + src: rootURI + 'preferences.xhtml', + scripts: [rootURI + 'preferences.js'] + }); + + Services.scriptloader.loadSubScript(rootURI + 'zotero-pdf-bakcground.js'); + PDFBackground.init({ id, version, rootURI }); + await PDFBackground.main(); +} + +function onMainWindowLoad({ window }) { + log("Zotero main window load") +} + +function onMainWindowUnload({ window }) { + log("Zotero main window unload") +} + +function shutdown() { + log("plugin Shutting down"); + PDFBackground?.removeAllStyle(); + PDFBackground = undefined; +} + +function uninstall() { + log("plugin Uninstalled"); + PDFBackground?.removeAllStyle(); +} diff --git a/chrome.manifest b/chrome.manifest deleted file mode 100644 index 98e43ca..0000000 --- a/chrome.manifest +++ /dev/null @@ -1,5 +0,0 @@ -content zotero-pdf-background content/ -locale zotero-pdf-background en-US locale/en-US/ -skin zotero-pdf-background default skin/ - -overlay chrome://zotero/content/zoteroPane.xul chrome://zotero-pdf-background/content/zotero-pdf-background.xul diff --git a/content/zotero-pdf-background.js b/content/zotero-pdf-background.js deleted file mode 100644 index ca8b67d..0000000 --- a/content/zotero-pdf-background.js +++ /dev/null @@ -1,184 +0,0 @@ -(() => { - - function to_s(obj) { - if (typeof obj === "string") - return obj; - const s = `${obj}`; - switch (s) { - case "[object Object]": - return JSON.stringify(obj); - case "[object Set]": - return JSON.stringify(Array.from(obj)); - default: - return s; - } - } - function format(...msg) { - return `Pdf-background: ${msg.map(to_s).join(" ")}`; - } - function debug(...msg) { - Zotero.debug(format(msg)); - } - - var pdf_background = class { - constructor() { - this.background_list=["default","daytime","nighttime","careeye","parchment"];//背景颜色列表 - this.setPref("defaultBackground",this.background_list[3]);//预先写入配置 - } - getPref(pref) { - return Zotero.Prefs.get(`extensions.pdf-bakcground.${pref}`, true); - } - setPref(pref, value) { - return Zotero.Prefs.set(`extensions.pdf-bakcground.${pref}`, value, true); - } - addEventListener(type, listener, priority) { - this._eventListeners.push({ priority: priority != null ? priority : 10, listener, type }); - this._eventListeners.sort((obj1, obj2) => obj1.priority - obj2.priority); - } - addToggleButton(readerWindow) { - if (this.hasToggle(readerWindow)) { - debug("addToggleButton: window already has toggle"); - return; - } - const defaultBackground = this.getPref("defaultBackground");//获得设置中背景颜色 - const toggle = readerWindow.document.createElement("button"); - toggle.setAttribute("id", "switch-toggle"); - toggle.setAttribute("title", "选择背景颜色"); - toggle.setAttribute("class","toolbarButton background-color"); - toggle.innerHTML=``; - toggle.onclick = () => { - var selector=readerWindow.document.querySelector("#background-selector"); - if(selector.hasAttribute("class")) - selector.removeAttribute("class") - else - selector.setAttribute("class","hidden") - }; - const middleToolbar = readerWindow.document.querySelector("#toolbarViewerMiddle"); - middleToolbar.appendChild(toggle); - - const selector = readerWindow.document.createElement("ul"); - selector.setAttribute("id", "background-selector"); - selector.setAttribute("class", "hidden"); - selector.innerHTML=` -
  • 默认
  • -
  • 日间
  • -
  • 夜间
  • -
  • 护眼
  • -
  • 羊皮纸
  • - `; - selector.onclick = (e) => { - this.backgroundSelectorOnClick(e,readerWindow); - } - middleToolbar.appendChild(selector); - } - hasToggle(readerWindow) { - return !!readerWindow.document.querySelector("#switch-toggle"); - } - backgroundSelectorOnClick(e,readerWindow) { - if(e.target.nodeName.toLowerCase()=="li"){ - var bg=e.target.getAttribute("value"); - } - this.setPref("defaultBackground",bg); - readerWindow.document.querySelector("body").setAttribute("class",bg); - //设置按钮 - readerWindow.document.querySelector("#background-selector li[select='true']").removeAttribute("select"); - readerWindow.document.querySelector("#background-selector li[value="+bg+"]").setAttribute("select","true"); - readerWindow.document.querySelector("#background-selector").setAttribute("class","hidden"); - return; - } - addWindowStyle(readerWindow){ - debug("adding style for added window tab"); - const style = readerWindow.document.createElement("link"); - style.setAttribute("type", "text/css"); - style.setAttribute("rel", "stylesheet"); - style.setAttribute("id", "pageBackground"); - style.setAttribute("href", "chrome://zotero-pdf-background/skin/pdf-background.css"); - const header = readerWindow.document.querySelector("head"); - header.appendChild(style); - var defaultBackground = this.getPref("defaultBackground");//获得设置中背景颜色 - if(defaultBackground==undefined)defaultBackground="careeye"; - readerWindow.document.querySelector("body").setAttribute("class",defaultBackground); - //设置按钮 - var ele; - if(ele=readerWindow.document.querySelector("#background-selector li[select='true']"))ele.removeAttribute("select"); - readerWindow.document.querySelector("#background-selector li[value="+defaultBackground+"]").setAttribute("select","true"); - } - hasWindowStyle(readerWindow) { - return !!readerWindow.document.querySelector("#pageBackground"); - } - addAllStyles() { - let counter = 0; - let win = window[counter]; - while (win) { - if (win.document.URL.includes("viewer.html")) { - this.addToggleButton(win); - this.addWindowStyle(win) - } - counter++; - win = window[counter]; - } - } - removeAllStyle() { - let counter = 0; - let win = window[counter]; - while (win) { - if (win.document.URL.includes("viewer.html")) { - win.document.querySelector("#switch-toggle").remove(); - win.document.querySelector("#pageBackground").remove(); - win.document.querySelector("body").removeAttribute("class"); - } - counter++; - win = window[counter]; - } - } - getTabWindowById(id) { - const tabIndex = Zotero_Tabs._tabs.findIndex((tab) => tab.id === id); - debug(`Select tab event tabindex: ${tabIndex}`); - if (tabIndex === -1) - return null; - const activeTabWindow = window[1 + tabIndex]; - return activeTabWindow; - } - getTabNameById(id) { - var _a, _b; - const name = (_b = (_a = Zotero_Tabs._tabs.find((tab) => tab.id === id)) == null ? void 0 : _a.title) != null ? _b : "Not found"; - return name; - } - async load(globals) { - this.globals = globals; - const notifierCallback = { - notify: async (event, type, ids, extraData) => { - if (event === "add") { - debug(`Tab with id ${ids[0]} added`); - debug("finding browser tab"); - debug("Trying to find window"); - const reader = Zotero.Reader.getByTabID(ids[0]); - await reader._initPromise; - const tabWindow = reader._iframeWindow; - debug(tabWindow); - debug(`Added tab "${this.getTabNameById(ids[0])}"`); - debug(`Added tab window readystate is ${tabWindow.document.readyState}`); - switch (tabWindow.document.readyState) { - case "uninitialized": { - setTimeout(() => { - tabWindow.document.onreadystatechange = () => debug("in readystatechange eventlistener:"); - debug(`Added tab windw readystate is ${tabWindow.document.readyState}`); - this.addPageStyle(tabWindow) - this.addToggleButton(tabWindow); - return; - }, 300); - } - case "complete": { - this.addToggleButton(tabWindow); - this.addWindowStyle(tabWindow) - } - } - } - } - }; - Zotero.Notifier.registerObserver(notifierCallback, ["tab"]); - this.strings = globals.document.getElementById("zotero-pdf-background-strings"); - } - }; - Zotero.pdf_background = new pdf_background(); -})(); diff --git a/content/zotero-pdf-background.xul b/content/zotero-pdf-background.xul deleted file mode 100644 index 61b03b4..0000000 --- a/content/zotero-pdf-background.xul +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/example1.jpg b/example1.jpg new file mode 100644 index 0000000..4bf79c4 Binary files /dev/null and b/example1.jpg differ diff --git a/example1.png b/example1.png deleted file mode 100644 index 1b209c2..0000000 Binary files a/example1.png and /dev/null differ diff --git a/example2.jpg b/example2.jpg new file mode 100644 index 0000000..f15f431 Binary files /dev/null and b/example2.jpg differ diff --git a/example2.png b/example2.png deleted file mode 100644 index 7acee6a..0000000 Binary files a/example2.png and /dev/null differ diff --git a/example3.jpg b/example3.jpg new file mode 100644 index 0000000..e19f25d Binary files /dev/null and b/example3.jpg differ diff --git a/example3.png b/example3.png deleted file mode 100644 index ec532d5..0000000 Binary files a/example3.png and /dev/null differ diff --git a/install.rdf b/install.rdf deleted file mode 100644 index a6619ba..0000000 --- a/install.rdf +++ /dev/null @@ -1,25 +0,0 @@ - - - - Background for Zotero Pdf Reader - Background theme for Zotero PDF Reader UI - pdf-background@juju.com - 0.0.2 - https://github.com/q77190858/zotero-pdf-background - Ju Ju - https://github.com/q77190858/zotero-pdf-background/releases/download/release/update.rdf - 2 - - - zotero@chnm.gmu.edu - 6.0.0 - 6.0.* - - - juris-m@juris-m.github.io - 6.0.0 - 6.0.* - - - - \ No newline at end of file diff --git a/locale/en-US/zotero-pdf-background.dtd b/locale/en-US/zotero-pdf-background.dtd deleted file mode 100644 index df20f6b..0000000 --- a/locale/en-US/zotero-pdf-background.dtd +++ /dev/null @@ -1 +0,0 @@ - diff --git a/locale/en-US/zotero-pdf-background.ftl b/locale/en-US/zotero-pdf-background.ftl new file mode 100644 index 0000000..b19a5c6 --- /dev/null +++ b/locale/en-US/zotero-pdf-background.ftl @@ -0,0 +1,2 @@ +zotero-pdf-background = + .label = zotero-pdf-background diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..0939870 --- /dev/null +++ b/manifest.json @@ -0,0 +1,15 @@ +{ + "manifest_version": 2, + "name": "Zotero PDF Background", + "version": "2.0", + "description": "Change PDF background color to care for eyes", + "homepage_url": "https://github.com/q77190858/zotero-pdf-background", + "applications": { + "zotero": { + "id": "zotero-pdf-background@example.com", + "update_url": "https://zotero-download.s3.amazonaws.com/tmp/zotero-pdf-background/updates-2.0.json", + "strict_min_version": "6.999", + "strict_max_version": "7.0.*" + } + } +} diff --git a/prefs.js b/prefs.js new file mode 100644 index 0000000..c9554b5 --- /dev/null +++ b/prefs.js @@ -0,0 +1 @@ +pref("extensions.zotero-pdf-bakcground.defaultBackground","careeye"); diff --git a/skin/pdf-background.css b/skin/pdf-background.css deleted file mode 100644 index 03c2a90..0000000 --- a/skin/pdf-background.css +++ /dev/null @@ -1,55 +0,0 @@ -body.default #viewer.pdfViewer > .page > .textLayer{display:block;} -body.daytime #viewer.pdfViewer > .page > .textLayer{display:block;background-color:rgba(243,243,243,0.5);} -body.nighttime #viewer.pdfViewer > .page > .textLayer{display:block;background-color:rgba(147,147,147,0.5);} -body.careeye #viewer.pdfViewer > .page > .textLayer{display:block;background-color:rgba(155,189,133,0.5);} -body.parchment #viewer.pdfViewer > .page > .textLayer{display:block;background-color:rgba(191,177,125,0.5);} - -.toolbar .toolbarButton.background-color::before { - content: "👁"; - font-size: 14px; - border-radius: 3px; - margin: -2px; - display: inline-block; - vertical-align: top; - position: relative; - z-index: 2; -} -.toolbar .toolbarButton.background-color .dropmarker{ - display: inline-block; - vertical-align: top; - width: 7px; - height: 4px; - position: relative; - z-index: 1; - margin: 6px -1px 0 2px; - background: url(resource://zotero/pdf-reader/images/searchbar-dropmarker@2x.png) no-repeat left top/100%; -} - -#toolbarViewerMiddle{ - position: relative; -} -.toolbar #background-selector{ - position:absolute; - right: 4px; - top:93%; - background:#fafafa; - box-shadow:1px 1px 1px #888 -} -.toolbar #background-selector > li{ - list-style:none; - padding: 1px 3px; -} -.toolbar #background-selector > li:hover{ - list-style:none; - padding-top:1px; - padding-bottom:1px; - cursor: pointer; - background-color:skyblue; -} -.toolbar #background-selector > li[select="true"]{ - list-style:none; - padding-top:1px; - padding-bottom:1px; - cursor: pointer; - background-color:dodgerblue; -} \ No newline at end of file diff --git a/zotero-pdf-backgroundv0.0.2.zip b/zotero-pdf-backgroundv0.0.2.zip deleted file mode 100644 index c598bf2..0000000 Binary files a/zotero-pdf-backgroundv0.0.2.zip and /dev/null differ diff --git a/zotero-pdf-bakcground.js b/zotero-pdf-bakcground.js new file mode 100644 index 0000000..4e8b990 --- /dev/null +++ b/zotero-pdf-bakcground.js @@ -0,0 +1,242 @@ +PDFBackground = { + id: null, + version: null, + rootURI: null, + name: "Zotero PDF Background", + initialized: false, + + init({ id, version, rootURI }) { + if (this.initialized) return; + this.id = id; + this.version = version; + this.rootURI = rootURI; + this.initialized = true; + this.background_list = ["default", "daytime", "nighttime", "careeye", "parchment"];//背景颜色列表 + }, + + log(msg) { + Zotero.debug("zotero-pdf-bakcground: " + msg); + }, + + + getPref(pref) { + return Zotero.Prefs.get(`extensions.pdf-bakcground.${pref}`, true); + }, + setPref(pref, value) { + return Zotero.Prefs.set(`extensions.pdf-bakcground.${pref}`, value, true); + }, + addToggleButton(browserWindow) { + if (!!browserWindow.document.querySelector("#switch-toggle")) { + log("addToggleButton: window already has toggle"); + return; + } + const defaultBackground = this.getPref("defaultBackground");//获得设置中背景颜色 + const style = browserWindow.document.createElement("style"); + style.setAttribute("type", "text/css"); + style.setAttribute("id", "toggle-button-style"); + style.innerHTML = ` + .toolbar #switch-toggle.background-color::before { + content: "👁"; + font-size: 20px; + border-radius: 3px; + margin: -2px; + display: inline-block; + vertical-align: top; + position: relative; + z-index: 2; + } + .toolbar #background-selector{ + position:absolute; + top:103%; + background: var(--material-toolbar); + border: var(--material-panedivider); + border-radius: 5px; + box-shadow: 0 0 0 1px rgba(0,0,0,.1),0 5px 10px rgba(0,0,0,.6); + padding: 5px; + } + .toolbar #background-selector > li{ + list-style: none; + line-height: 28px; + border-radius: 5px; + text-align: center; + padding: 1px 13px; + } + @media (prefers-color-scheme: dark){ + .toolbar #background-selector > li{ + color:#ddd; + } + } + + .toolbar #background-selector > li:hover{ + background: var(--fill-quinary); + } + .toolbar #background-selector > li[select="true"]:before{ + content: "✓"; + position: absolute; + margin-inline-start: -13px; + height: 28px; + display: flex; + align-items: center; + } + ` + browserWindow.document.querySelector("head").appendChild(style); + const toggle = browserWindow.document.createElement("button"); + toggle.setAttribute("id", "switch-toggle"); + toggle.setAttribute("title", "选择背景颜色"); + toggle.setAttribute("class", "toolbar-button toolbar-dropdown-button background-color"); + toggle.innerHTML = ` + + + + `; + toggle.onclick = () => { + var selector = browserWindow.document.querySelector("#background-selector"); + if (selector.hasAttribute("style")) + selector.removeAttribute("style") + else + selector.setAttribute("style", "display:none") + }; + + const selector = browserWindow.document.createElement("ul"); + selector.setAttribute("id", "background-selector"); + selector.setAttribute("style", "display:none"); + selector.innerHTML = ` +
  • 默认
  • +
  • 日间
  • +
  • 夜间
  • +
  • 护眼
  • +
  • 羊皮纸
  • + `; + selector.onclick = (e) => { + this.backgroundSelectorOnClick(e, browserWindow); + } + const divider = browserWindow.document.createElement("div"); + divider.setAttribute("class", "divider") + divider.setAttribute("id", "background-selector-divider") + const middleToolbar = browserWindow.document.querySelector("#reader-ui .toolbar div.center"); + middleToolbar.insertBefore(divider, middleToolbar.firstChild); + middleToolbar.insertBefore(selector, middleToolbar.firstChild); + middleToolbar.insertBefore(toggle, middleToolbar.firstChild); + log("success add toggle button") + }, + backgroundSelectorOnClick(e, browserWindow) { + if (e.target.nodeName.toLowerCase() == "li") { + var bg = e.target.getAttribute("value"); + } + this.setPref("defaultBackground", bg); + for (let iframe of browserWindow.document.querySelectorAll("iframe[src='pdf/web/viewer.html']")) { + var classList = iframe.contentWindow.document.querySelector("body").classList + for (let cls of this.background_list) { + classList.remove(cls) + } + classList.add(bg); + } + //设置按钮 + browserWindow.document.querySelector("#background-selector li[select='true']")?.removeAttribute("select"); + browserWindow.document.querySelector("#background-selector li[value=" + bg + "]").setAttribute("select", "true"); + browserWindow.document.querySelector("#background-selector").setAttribute("style", "display:none"); + return; + }, + addWindowStyle(iframeWindow) { + if (!!iframeWindow.document.querySelector("#pageBackground")) return + debug("adding style for added window tab"); + const style = iframeWindow.document.createElement("style"); + style.setAttribute("type", "text/css"); + style.setAttribute("id", "pageBackground"); + style.innerHTML = ` + body.default #viewer.pdfViewer > .page > .textLayer{display:block;} + body.daytime #viewer.pdfViewer > .page > .textLayer{display:block;background-color:rgb(225,225,225);} + body.nighttime #viewer.pdfViewer > .page > .textLayer{display:block;background-color:rgb(5,9,5);} + body.careeye #viewer.pdfViewer > .page > .textLayer{display:block;background-color:rgb(5,90,0);} + body.parchment #viewer.pdfViewer > .page > .textLayer{display:block;background-color:rgb(95,60,0);} + ` + const header = iframeWindow.document.querySelector("head"); + header.appendChild(style); + var defaultBackground = this.getPref("defaultBackground");//获得设置中背景颜色 + if (defaultBackground == undefined) defaultBackground = "careeye"; + iframeWindow.document.querySelector("body").setAttribute("class", defaultBackground); + log("success add window style") + }, + addAllStyles() { + log("add style to all open tabs") + var windows = Zotero.getMainWindows(); + for (let win of windows) { + if (!win.ZoteroPane) continue; + var browsers = win.document.querySelectorAll("browser.reader") + for (let bro of browsers) { + var browserWindow = bro.contentWindow + log(browserWindow.document.readyState) + this.addToggleButton(browserWindow) + for (let iframe of browserWindow.document.querySelectorAll("iframe[src='pdf/web/viewer.html']")) { + this.addWindowStyle(iframe.contentWindow) + } + browserWindow.document.querySelector("#secondary-view").addEventListener('DOMNodeInserted', (e) => { + log("secondary-view dom node inserted") + const secondIframe = browserWindow.document.querySelector("#secondary-view iframe[src='pdf/web/viewer.html']") + secondIframe.contentWindow.onload = () => { + log("second iframeWindow loaded async, add style"); + this.addWindowStyle(secondIframe.contentWindow); + } + }, false); + } + } + }, + removeAllStyle() { + var windows = Zotero.getMainWindows(); + for (let win of windows) { + if (!win.ZoteroPane) continue; + var browsers = win.document.querySelectorAll("browser.reader") + for (let bro of browsers) { + bro.contentWindow.document.querySelector("#switch-toggle").remove() + bro.contentWindow.document.querySelector("#toggle-button-style").remove() + bro.contentWindow.document.querySelector("#background-selector").remove() + bro.contentWindow.document.querySelector("#background-selector-divider").remove() + for (let iframe of bro.contentDocument.querySelectorAll("iframe[src='pdf/web/viewer.html']")) { + iframe.contentDocument.querySelector("body").removeAttribute("class"); + } + } + } + }, + async main() { + // Global properties are included automatically in Zotero 7 + var host = new URL('https://foo.com/path').host; + this.log(`Host is ${host}`); + + // Retrieve a global pref + this.log(`defaultBackground is ${Zotero.Prefs.get('extensions.zotero-pdf-bakcground.defaultBackground', "eyecare")}`); + setTimeout(() => { + this.addAllStyles(); + }, 1000); + // regist tab add listener + const notifierCallback = { + notify: async (event, type, ids, extraData) => { + // log("tab " + event + extraData[ids[0]]) + if ((event == "load" || event == "add") && type == "tab" && extraData[ids[0]].type == "reader") { + log(`Tab with id ${ids[0]} ${event}`); + const reader = Zotero.Reader.getByTabID(ids[0]); + await reader._initPromise; + const browserWindow = reader._iframeWindow + const iframes = browserWindow.document.querySelectorAll("iframe[src='pdf/web/viewer.html']") + for (let iframe of iframes) { + const iframeWindow = iframe.contentWindow + iframeWindow.onload = () => { + log(`uninitialized tab window readystate is ${iframeWindow.document.readyState}`); + log("iframeWindow load complete async"); + this.addToggleButton(browserWindow); + this.addWindowStyle(iframeWindow); + } + } + browserWindow.document.querySelector("#secondary-view").addEventListener('DOMNodeInserted', (e) => { + log("secondary-view dom node inserted") + const secondIframe = browserWindow.document.querySelector("#secondary-view iframe[src='pdf/web/viewer.html']") + secondIframe.contentWindow.onload = () => { + log("second iframeWindow loaded async, add style"); + this.addWindowStyle(secondIframe.contentWindow); + } + }, false); + } + } + }; + Zotero.Notifier.registerObserver(notifierCallback, ["tab"]); + }, +};