chore: initial project commit
This commit is contained in:
70
addon/bootstrap.js
vendored
Normal file
70
addon/bootstrap.js
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
/* eslint-disable no-undef */
|
||||
|
||||
var chromeHandle;
|
||||
|
||||
async function startup({ id, version, rootURI }, reason) {
|
||||
await Zotero.initializationPromise;
|
||||
|
||||
try {
|
||||
const aomStartup = Cc["@mozilla.org/addons/addon-manager-startup;1"].getService(
|
||||
Ci.amIAddonManagerStartup
|
||||
);
|
||||
const manifestURI = Services.io.newURI(rootURI + "manifest.json");
|
||||
chromeHandle = aomStartup.registerChrome(manifestURI, [
|
||||
["content", "orgexportannotations", rootURI + "content/"],
|
||||
]);
|
||||
|
||||
Services.scriptloader.loadSubScript(rootURI + "content/scripts/index.js");
|
||||
|
||||
if (typeof Zotero.OrgExportAnnotations === "undefined") {
|
||||
throw new Error("Zotero.OrgExportAnnotations not loaded from index.js");
|
||||
}
|
||||
|
||||
await Zotero.OrgExportAnnotations.init({ id, version, rootURI });
|
||||
await Zotero.OrgExportAnnotations.hooks.onStartup();
|
||||
} catch (error) {
|
||||
Zotero.logError("[OrgExportAnnotations] Startup failed: " + error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async function onMainWindowLoad({ window }) {
|
||||
try {
|
||||
await Zotero.OrgExportAnnotations?.hooks?.onMainWindowLoad(window);
|
||||
} catch (error) {
|
||||
Zotero.logError("[OrgExportAnnotations] onMainWindowLoad failed: " + error);
|
||||
}
|
||||
}
|
||||
|
||||
async function onMainWindowUnload({ window }) {
|
||||
try {
|
||||
await Zotero.OrgExportAnnotations?.hooks?.onMainWindowUnload(window);
|
||||
} catch (error) {
|
||||
Zotero.logError("[OrgExportAnnotations] onMainWindowUnload failed: " + error);
|
||||
}
|
||||
}
|
||||
|
||||
function shutdown({ id, version, rootURI }, reason) {
|
||||
if (reason === APP_SHUTDOWN) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Zotero.OrgExportAnnotations?.hooks?.onShutdown();
|
||||
} catch (error) {
|
||||
Zotero.logError("[OrgExportAnnotations] onShutdown failed: " + error);
|
||||
}
|
||||
|
||||
try {
|
||||
chromeHandle?.destruct();
|
||||
} catch (error) {
|
||||
Zotero.logError("[OrgExportAnnotations] Failed to destruct chrome handle: " + error);
|
||||
}
|
||||
chromeHandle = null;
|
||||
|
||||
delete Zotero.OrgExportAnnotations;
|
||||
}
|
||||
|
||||
function install() {}
|
||||
|
||||
function uninstall() {}
|
||||
Reference in New Issue
Block a user