-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.js
More file actions
78 lines (64 loc) · 2.34 KB
/
bootstrap.js
File metadata and controls
78 lines (64 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/* ZotFetch Bootstrap - Zotero 8 */
// Global namespace
var ZotFetchPlugin = {
PLUGIN_ID: "zotfetch@edslab.research",
initialized: false,
rootURI: null,
init({ id, version, rootURI }) {
if (this.initialized) return;
this.PLUGIN_ID = id;
this.rootURI = rootURI;
this.initialized = true;
Zotero.debug(`ZotFetch ${version} initialized from ${rootURI}`);
},
async startup({ id, version, rootURI }, reason) {
try {
this.init({ id, version, rootURI });
Services.scriptloader.loadSubScript(rootURI + "chrome/content/utils.mjs");
Services.scriptloader.loadSubScript(rootURI + "chrome/content/prefs.mjs");
Services.scriptloader.loadSubScript(rootURI + "chrome/content/cooldown.mjs");
Services.scriptloader.loadSubScript(rootURI + "chrome/content/fetch.mjs");
Services.scriptloader.loadSubScript(rootURI + "chrome/content/ui.mjs");
if (typeof ZotFetchUI === "undefined") {
throw new Error("ZotFetchUI not loaded");
}
await ZotFetchUI.init();
ZotFetchUI.addToAllWindows();
Zotero.debug("ZotFetch startup complete");
} catch (error) {
Zotero.logError(error);
}
},
shutdown({ id, version, rootURI }, reason) {
try {
Zotero.getMainWindows().forEach(win => ZotFetchUI.removeFromWindow(win));
if (ZotFetchUI.menuID && Zotero.MenuManager?.unregisterMenu) {
Zotero.MenuManager.unregisterMenu(ZotFetchUI.menuID);
}
Zotero.debug("ZotFetch shutdown complete");
} catch (error) {
Zotero.logError(error);
}
},
install({ id, version, rootURI }, reason) {
Zotero.debug("ZotFetch installed");
},
uninstall({ id, version, rootURI }, reason) {
Zotero.debug("ZotFetch uninstalled");
},
onMainWindowLoad({ window }) {
if (window.ZoteroPane) {
ZotFetchUI.addToWindow(window);
}
},
onMainWindowUnload({ window }) {
ZotFetchUI.removeFromWindow(window);
}
};
// Export for Zotero bootstrap
this.startup = ZotFetchPlugin.startup.bind(ZotFetchPlugin);
this.shutdown = ZotFetchPlugin.shutdown.bind(ZotFetchPlugin);
this.install = ZotFetchPlugin.install.bind(ZotFetchPlugin);
this.uninstall = ZotFetchPlugin.uninstall.bind(ZotFetchPlugin);
this.onMainWindowLoad = ZotFetchPlugin.onMainWindowLoad.bind(ZotFetchPlugin);
this.onMainWindowUnload = ZotFetchPlugin.onMainWindowUnload.bind(ZotFetchPlugin);