Skip to content

Commit

Permalink
Remove Zotero 6 compatibility code
Browse files Browse the repository at this point in the history
  • Loading branch information
northword committed Jul 1, 2023
1 parent d2d8922 commit 0b74eab
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 39 deletions.
42 changes: 7 additions & 35 deletions addon/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,13 @@ async function startup({ id, version, resourceURI, rootURI }, reason) {
rootURI = resourceURI.spec;
}

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/"],
]);
} else {
setDefaultPrefs(rootURI);
}
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/"],
]);

/**
* Global variables for plugin code.
Expand Down Expand Up @@ -124,27 +120,3 @@ function shutdown({ id, version, resourceURI, rootURI }, reason) {
}

function uninstall(data, reason) {}

// Loads default preferences from defaults/preferences/prefs.js in Zotero 6
function setDefaultPrefs(rootURI) {
var branch = Services.prefs.getDefaultBranch("");
var obj = {
pref(pref, value) {
switch (typeof value) {
case "boolean":
branch.setBoolPref(pref, value);
break;
case "string":
branch.setStringPref(pref, value);
break;
case "number":
branch.setIntPref(pref, value);
break;
default:
Zotero.logError(`Invalid type '${typeof value}' for pref '${pref}'`);
}
},
};
Zotero.getMainWindow().console.log(rootURI + "prefs.js");
Services.scriptloader.loadSubScript(rootURI + "prefs.js", obj);
}
4 changes: 0 additions & 4 deletions scripts/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,9 @@ async function main() {

const optionsAddon = {
files: [
join(buildDir, "**/*.rdf"),
join(buildDir, "**/*.dtd"),
join(buildDir, "**/*.xul"),
join(buildDir, "**/*.xhtml"),
join(buildDir, "**/*.json"),
join(buildDir, "addon/prefs.js"),
join(buildDir, "addon/chrome.manifest"),
join(buildDir, "addon/manifest.json"),
join(buildDir, "addon/bootstrap.js"),
"update.json",
Expand Down

0 comments on commit 0b74eab

Please sign in to comment.