This repository has been archived by the owner on Jan 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
xiangyu
committed
Dec 18, 2022
1 parent
aafbeea
commit 956d5df
Showing
22 changed files
with
1,212 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
/* Copyright 2012 Will Shanks. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
if (typeof Zotero == "undefined") { | ||
var Zotero; | ||
} | ||
|
||
var chromeHandle; | ||
|
||
// In Zotero 6, bootstrap methods are called before Zotero is initialized, and using include.js | ||
// to get the Zotero XPCOM service would risk breaking Zotero startup. Instead, wait for the main | ||
// Zotero window to open and get the Zotero object from there. | ||
// | ||
// In Zotero 7, bootstrap methods are not called until Zotero is initialized, and the 'Zotero' is | ||
// automatically made available. | ||
async function waitForZotero() { | ||
if (typeof Zotero != "undefined") { | ||
await Zotero.initializationPromise; | ||
} | ||
|
||
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); | ||
var windows = Services.wm.getEnumerator("navigator:browser"); | ||
var found = false; | ||
while (windows.hasMoreElements()) { | ||
let win = windows.getNext(); | ||
if (win.Zotero) { | ||
Zotero = win.Zotero; | ||
found = true; | ||
break; | ||
} | ||
} | ||
if (!found) { | ||
await new Promise((resolve) => { | ||
var listener = { | ||
onOpenWindow: function (aWindow) { | ||
// Wait for the window to finish loading | ||
let domWindow = aWindow | ||
.QueryInterface(Ci.nsIInterfaceRequestor) | ||
.getInterface(Ci.nsIDOMWindowInternal || Ci.nsIDOMWindow); | ||
domWindow.addEventListener( | ||
"load", | ||
function () { | ||
domWindow.removeEventListener("load", arguments.callee, false); | ||
if (domWindow.Zotero) { | ||
Services.wm.removeListener(listener); | ||
Zotero = domWindow.Zotero; | ||
resolve(); | ||
} | ||
}, | ||
false | ||
); | ||
}, | ||
}; | ||
Services.wm.addListener(listener); | ||
}); | ||
} | ||
await Zotero.initializationPromise; | ||
} | ||
|
||
function install(data, reason) {} | ||
|
||
async function startup({ id, version, resourceURI, rootURI }, reason) { | ||
await waitForZotero(); | ||
|
||
// String 'rootURI' introduced in Zotero 7 | ||
if (!rootURI) { | ||
rootURI = resourceURI.spec; | ||
} | ||
|
||
const window = Zotero.getMainWindow(); | ||
// Global variables for plugin code | ||
const ctx = { | ||
Zotero, | ||
rootURI, | ||
window, | ||
document: window.document, | ||
ZoteroPane: Zotero.getActiveZoteroPane(), | ||
}; | ||
|
||
Services.scriptloader.loadSubScript( | ||
`${rootURI}/chrome/content/scripts/index.js`, | ||
ctx | ||
); | ||
|
||
if (Zotero.platformMajorVersion >= 102) { | ||
var aomStartup = Components.classes[ | ||
"@mozilla.org/addons/addon-manager-startup;1" | ||
].getService(Components.interfaces.amIAddonManagerStartup); | ||
var manifestURI = Services.io.newURI(rootURI + "manifest.json"); | ||
chromeHandle = aomStartup.registerChrome(manifestURI, [ | ||
["content", "__addonRef__", rootURI + "chrome/content/"], | ||
["locale", "__addonRef__", "en-US", rootURI + "chrome/locale/en-US/"], | ||
["locale", "__addonRef__", "zh-CN", rootURI + "chrome/locale/zh-CN/"], | ||
]); | ||
} | ||
} | ||
|
||
function shutdown({ id, version, resourceURI, rootURI }, reason) { | ||
if (reason === APP_SHUTDOWN) { | ||
return; | ||
} | ||
if (typeof Zotero === "undefined") { | ||
Zotero = Components.classes["@zotero.org/Zotero;1"].getService( | ||
Components.interfaces.nsISupports | ||
).wrappedJSObject; | ||
} | ||
Zotero.PDFPreview.events.onUnInit(Zotero); | ||
|
||
Cc["@mozilla.org/intl/stringbundle;1"] | ||
.getService(Components.interfaces.nsIStringBundleService) | ||
.flushBundles(); | ||
|
||
Cu.unload(`${rootURI}/chrome/content/scripts/index.js`); | ||
|
||
if (chromeHandle) { | ||
chromeHandle.destruct(); | ||
chromeHandle = null; | ||
} | ||
} | ||
|
||
function uninstall(data, reason) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,3 @@ | ||
content __addonRef__ chrome/content/ | ||
skin __addonRef__ default chrome/skin/default/__addonRef__/ | ||
locale __addonRef__ en-US chrome/locale/en-US/ | ||
locale __addonRef__ zh-CN chrome/locale/zh-CN/ | ||
|
||
overlay chrome://zotero/content/zoteroPane.xul chrome://__addonRef__/content/overlay.xul | ||
overlay chrome://zotero/content/preferences/preferences.xul chrome://__addonRef__/content/preferences.xul |
File renamed without changes
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<vbox id="zotero-prefpane-__addonRef__"> | ||
<groupbox> | ||
<label><html:h2>Preview Settings</html:h2></label> | ||
<hbox> | ||
<checkbox | ||
preference="extensions.zotero.__addonRef__.enableSplit" | ||
label="&zotero.__addonRef__.pref.enableSplit.label;" | ||
/> | ||
<radiogroup | ||
preference="extensions.zotero.__addonRef__.splitType" | ||
orient="horizontal" | ||
> | ||
<radio | ||
label="&zotero.__addonRef__.pref.splitBefore.label;" | ||
value="before" | ||
></radio> | ||
<radio | ||
label="&zotero.__addonRef__.pref.splitAfter.label;" | ||
value="after" | ||
></radio> | ||
</radiogroup> | ||
</hbox> | ||
<checkbox | ||
preference="extensions.zotero.__addonRef__.enableTab" | ||
label="&zotero.__addonRef__.pref.enableTab.label;" | ||
/> | ||
<hbox> | ||
<checkbox | ||
preference="extensions.zotero.__addonRef__.showToolInSplit" | ||
label="&zotero.__addonRef__.pref.showToolInSplit.label;" | ||
/> | ||
<checkbox | ||
preference="extensions.zotero.__addonRef__.showToolInTab" | ||
label="&zotero.__addonRef__.pref.showToolInTab.label;" | ||
/> | ||
</hbox> | ||
<checkbox | ||
preference="extensions.zotero.__addonRef__.showAnnotations" | ||
label="&zotero.__addonRef__.pref.showAnnotations.label;" | ||
/> | ||
<checkbox | ||
preference="extensions.zotero.__addonRef__.showHover" | ||
label="&zotero.__addonRef__.pref.showHover.label;" | ||
/> | ||
<checkbox | ||
preference="extensions.zotero.__addonRef__.enableJump" | ||
label="&zotero.__addonRef__.pref.enableJump.label;" | ||
/> | ||
<checkbox | ||
preference="extensions.zotero.__addonRef__.darkMode" | ||
label="&zotero.__addonRef__.pref.darkMode.label;" | ||
/> | ||
<hbox> | ||
<html:label for="zotero-prefpane-__addonRef__-previewPageNum" | ||
>&zotero.__addonRef__.pref.previewPageNumBefore.label;</html:label | ||
> | ||
<html:input | ||
type="text" | ||
id="zotero-prefpane-__addonRef__-previewPageNum" | ||
preference="extensions.zotero.__addonRef__.previewPageNum" | ||
></html:input> | ||
<html:label | ||
>&zotero.__addonRef__.pref.previewPageNumAfter.label;</html:label | ||
> | ||
</hbox> | ||
<hbox> | ||
<html:label for="zotero-prefpane-__addonRef__-previewTabName" | ||
>&zotero.__addonRef__.pref.previewTabNameBefore.label;</html:label | ||
> | ||
<html:input | ||
type="text" | ||
id="zotero-prefpane-__addonRef__-previewTabName" | ||
preference="extensions.zotero.__addonRef__.previewTabName" | ||
></html:input> | ||
<html:label | ||
>&zotero.__addonRef__.pref.previewTabNameAfter.label;</html:label | ||
> | ||
</hbox> | ||
<label | ||
value="&zotero.__addonRef__.help.feedback.label;" | ||
class="zotero-text-link" | ||
href="__homepage__" | ||
></label> | ||
<hbox> | ||
<label value="&zotero.__addonRef__.help.version.label;" /> | ||
<label value="&zotero.__addonRef__.help.releasetime.label;" /> | ||
</hbox> | ||
</groupbox> | ||
</vbox> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,10 +12,11 @@ | |
em:creator="__author__" | ||
em:description="__description__" | ||
em:homepageURL="__homepage__" | ||
em:iconURL="chrome://__addonRef__/skin/favicon.png" | ||
em:updateURL="https://raw.githubusercontent.com/windingwind/zotero-pdf-preview/master/update.rdf">> | ||
<em:type>2</em:type> | ||
<em:targetApplication RDF:resource="rdf:#$x61SL3"/> | ||
em:iconURL="chrome://__addonRef__/content/icons/favicon.png" | ||
em:updateURL="__updaterdf__" | ||
em:multiprocessCompatible="true" | ||
em:bootstrap="true">> <em:type>2</em:type> | ||
<em:targetApplication RDF:resource="rdf:#$x61SL3" /> | ||
<em:targetApplication> | ||
<Description> | ||
<em:id>[email protected]</em:id> | ||
|
@@ -30,5 +31,5 @@ | |
<em:maxVersion>*</em:maxVersion> | ||
</Description> | ||
</em:targetApplication> | ||
</RDF:Description> | ||
</RDF:RDF> | ||
</RDF:Description> | ||
</RDF:RDF> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"manifest_version": 2, | ||
"name": "__addonName__", | ||
"version": "__buildVersion__", | ||
"description": "__description__", | ||
"author": "__author__", | ||
"icons": { | ||
"96": "chrome/content/icons/favicon.png" | ||
}, | ||
"applications": { | ||
"zotero": { | ||
"id": "__addonID__", | ||
"update_url": "__updaterdf__", | ||
"strict_min_version": "6.999", | ||
"strict_max_version": "7.0.*" | ||
} | ||
} | ||
} |
Oops, something went wrong.