build.sh, options consumed by gulpfile.js, and secrets in config.sh), and runtime constants baked into every build via zotero_config.js (the ZOTERO_CONFIG object). Understanding both layers is necessary when cutting a release, customizing a build for local development, or wiring up a new deployment target.
build.sh Flags
build.sh is the top-level entry point for all connector builds. It coordinates resource copying, calls npx gulp for script processing, and assembles the per-browser output directories under build/.
string
A string of platform character codes specifying which platforms to build. Characters can be combined (e.g.,
-p bs builds both).Defaults to all platforms (
b and s) when omitted.string
Sets the connector version string embedded in manifests and
zotero.js. Injected into manifest.json via "version": "AUTOFILLED" replacement and into zotero.js via this.version replacement.Defaults to 4.999.0 when omitted (also the gulp default).boolean
Debug mode. When set:
- The translator tester tool (
tools/testTranslators/) is included in the build - Test libraries (
mocha,chai,sinon,bluebird) are copied intobuild/*/lib/ - The
test/directory is retained in the output - Gulp is invoked without the
-p(production) flag, so minification is skipped
boolean
Prints usage information and exits.
build.sh sources config.sh (if it exists) before running. Variables set in config.sh override defaults used during packaging and deployment steps.gulpfile.js Options
gulpfile.js is invoked by build.sh via npx gulp process-custom-scripts. It handles JSX transpilation (via Babel), browser-specific replacements, script list injection into manifests, and source map generation. Arguments are parsed with yargs.
boolean
default:"false"
Production mode. When
true:- The translator tester inject scripts (
translatorTester_messages.js,translatorTester_inject.js) are excluded from injected script lists - The translator tester background script (
translatorTester_background.js) is excluded from background script lists - The test inject file (
test/testInject.js) is excluded from the MV3 inject list <!--BEGIN DEBUG-->...<!--END DEBUG-->HTML comment blocks are stripped from HTML files
-pstring
default:"4.999.0"
Sets the version string injected into
manifest.json files (replacing the "version": "AUTOFILLED" sentinel) and into zotero.js (replacing the this.version assignment). Passed through from build.sh’s -v VERSION flag.build.sh as:
config.sh Variables
config.sh is sourced by build.sh when present. It is never committed to source control — it contains signing credentials and deployment secrets. The repository provides config.sh-sample as a template:
ZOTERO_CONFIG Constants
src/common/zotero_config.js defines the ZOTERO_CONFIG constant object, which is bundled into every build. It contains all runtime URLs, OAuth credentials, and feature flags. Values here are baked in at build time and cannot be changed at runtime without rebuilding.
Environment Variables for Testing
build.sh checks several environment variables to determine which browser to target when running tests:
When any test variable is set, the corresponding platform is built regardless of
-p flags. When no test variable and no -p flag is provided, all platforms are built.
Manifest Permissions
Manifest V2 (manifest.json) — Firefox and legacy Chromium
Manifest V3 (manifest-v3.json) — Chrome/Edge (MV3), minimum version 88
Required Permissions
http://*/*, https://*/* — Host access for content script injection and XHR to the local connector server.tabs — Reading tab URLs and IDs, sending messages to tabs.contextMenus — Right-click context menu integration.cookies — Collecting cookies via browser.cookies.getAll for callMethodWithCookies.storage — browser.storage.local for preferences (10 MB limit).scripting — Dynamic content script injection (MV3 replacement for tabs.executeScript).webRequest — Intercepting requests for content-type handling and user-agent replacement.webRequestBlocking — Synchronous request blocking (MV2 only; MV3 uses declarativeNetRequest).webNavigation — Detecting page navigations for proxy detection and translator triggering.declarativeNetRequest — Style intercept rules for importable file type detection.offscreen (MV3 only) — Creating offscreen documents for translation sandboxes.Optional Permissions
management — Requested on demand (within a user gesture) when submitting debug reports or error reports, to enumerate installed extensions for system info.clipboardWrite — Requested on demand for the “Copy to Clipboard” button in the debug report confirmation dialog.In the MV3 manifest, broad host access (
http://*/*, https://*/*) is declared under host_permissions rather than permissions, reflecting the MV3 split between API permissions and host access. webRequestBlocking is removed in MV3; blocking behavior is handled by declarativeNetRequest rules in styleInterceptRules.json.