2023-04-23 07:57:55 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
# Copyright (c) 2011 Zotero
|
|
|
|
# Center for History and New Media
|
|
|
|
# George Mason University, Fairfax, Virginia, USA
|
|
|
|
# http://zotero.org
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2023-04-29 09:49:55 +00:00
|
|
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
APP_ROOT_DIR="$(dirname "$SCRIPT_DIR")"
|
|
|
|
. "$APP_ROOT_DIR/config.sh"
|
|
|
|
cd "$APP_ROOT_DIR"
|
2023-04-23 07:57:55 +00:00
|
|
|
|
|
|
|
function usage {
|
|
|
|
cat >&2 <<DONE
|
|
|
|
Usage: $0 -p platforms [-s]
|
|
|
|
Options
|
|
|
|
-p PLATFORMS Platforms to build (m=Mac, w=Windows, l=Linux)
|
|
|
|
DONE
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
BUILD_MAC=0
|
|
|
|
BUILD_WIN=0
|
|
|
|
BUILD_LINUX=0
|
|
|
|
while getopts "p:s" opt; do
|
|
|
|
case $opt in
|
|
|
|
p)
|
|
|
|
for i in `seq 0 1 $((${#OPTARG}-1))`
|
|
|
|
do
|
|
|
|
case ${OPTARG:i:1} in
|
|
|
|
m) BUILD_MAC=1;;
|
|
|
|
w) BUILD_WIN=1;;
|
|
|
|
l) BUILD_LINUX=1;;
|
|
|
|
*)
|
|
|
|
echo "$0: Invalid platform option ${OPTARG:i:1}"
|
|
|
|
usage
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift $((OPTIND-1)); OPTIND=1
|
|
|
|
done
|
|
|
|
|
|
|
|
# Require at least one platform
|
|
|
|
if [[ $BUILD_MAC == 0 ]] && [[ $BUILD_WIN == 0 ]] && [[ $BUILD_LINUX == 0 ]]; then
|
|
|
|
usage
|
|
|
|
fi
|
|
|
|
|
|
|
|
function replace_line {
|
|
|
|
pattern=$1
|
|
|
|
replacement=$2
|
|
|
|
file=$3
|
|
|
|
|
|
|
|
if egrep -q "$pattern" "$file"; then
|
|
|
|
perl -pi -e "s/$pattern/$replacement/" "$file"
|
|
|
|
else
|
|
|
|
echo "$pattern" not found in "$file" -- aborting 2>&1
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function remove_line {
|
|
|
|
pattern=$1
|
|
|
|
file=$2
|
|
|
|
|
|
|
|
if egrep -q "$pattern" "$file"; then
|
|
|
|
egrep -v "$pattern" "$file" > "$file.tmp"
|
|
|
|
mv "$file.tmp" "$file"
|
|
|
|
else
|
2024-04-08 05:45:00 +00:00
|
|
|
echo "$pattern" not found in "$file" -- aborting 2>&1
|
2023-04-23 07:57:55 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2023-05-26 10:43:15 +00:00
|
|
|
function get_utf16_chars {
|
|
|
|
str=$(echo -n "$1" | xxd -p | fold -w 2 | sed -r 's/(.+)/\\\\x{\1}\\\\x{00}/')
|
|
|
|
# Add NUL padding
|
|
|
|
if [ -n "${2:-}" ]; then
|
|
|
|
# Multiply characters x 2 for UTF-16
|
|
|
|
for i in `seq 1 $(($2 * 2))`; do
|
|
|
|
str+=$(echo '\\x{00}')
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
echo $str | xargs | sed 's/ //g'
|
|
|
|
}
|
|
|
|
|
2023-04-23 07:57:55 +00:00
|
|
|
#
|
|
|
|
# Make various modifications to the stock Firefox app
|
|
|
|
#
|
|
|
|
function modify_omni {
|
2024-03-31 10:28:51 +00:00
|
|
|
platform=$1
|
|
|
|
|
2023-04-23 07:57:55 +00:00
|
|
|
mkdir omni
|
|
|
|
mv omni.ja omni
|
|
|
|
cd omni
|
|
|
|
# omni.ja is an "optimized" ZIP file, so use a script from Mozilla to avoid a warning from unzip
|
|
|
|
# here and to make it work after rezipping below
|
2023-04-29 09:49:55 +00:00
|
|
|
python3 "$APP_ROOT_DIR/scripts/optimizejars.py" --deoptimize ./ ./ ./
|
2023-04-23 07:57:55 +00:00
|
|
|
rm -f omni.ja.log
|
|
|
|
unzip omni.ja
|
|
|
|
rm omni.ja
|
|
|
|
|
2023-11-05 22:17:12 +00:00
|
|
|
replace_line 'BROWSER_CHROME_URL:.+' 'BROWSER_CHROME_URL: "chrome:\/\/zotero\/content\/zoteroPane.xhtml",' modules/AppConstants.sys.mjs
|
2023-04-23 07:57:55 +00:00
|
|
|
|
|
|
|
# https://firefox-source-docs.mozilla.org/toolkit/components/telemetry/internals/preferences.html
|
|
|
|
#
|
|
|
|
# It's not clear that most of these do anything anymore when not compiled in, but just in case
|
2023-11-05 22:17:12 +00:00
|
|
|
replace_line 'MOZ_REQUIRE_SIGNING:' 'MOZ_REQUIRE_SIGNING: false \&\&' modules/AppConstants.sys.mjs
|
|
|
|
replace_line 'MOZ_DATA_REPORTING:' 'MOZ_DATA_REPORTING: false \&\&' modules/AppConstants.sys.mjs
|
|
|
|
replace_line 'MOZ_SERVICES_HEALTHREPORT:' 'MOZ_SERVICES_HEALTHREPORT: false \&\&' modules/AppConstants.sys.mjs
|
|
|
|
replace_line 'MOZ_TELEMETRY_REPORTING:' 'MOZ_TELEMETRY_REPORTING: false \&\&' modules/AppConstants.sys.mjs
|
|
|
|
replace_line 'MOZ_TELEMETRY_ON_BY_DEFAULT:' 'MOZ_TELEMETRY_ON_BY_DEFAULT: false \&\&' modules/AppConstants.sys.mjs
|
|
|
|
replace_line 'MOZ_CRASHREPORTER:' 'MOZ_CRASHREPORTER: false \&\&' modules/AppConstants.sys.mjs
|
|
|
|
replace_line 'MOZ_UPDATE_CHANNEL:.+' 'MOZ_UPDATE_CHANNEL: "none",' modules/AppConstants.sys.mjs
|
|
|
|
replace_line '"https:\/\/[^\/]+mozilla.com.+"' '""' modules/AppConstants.sys.mjs
|
2023-04-23 07:57:55 +00:00
|
|
|
|
2023-05-20 11:22:22 +00:00
|
|
|
# Don't use Mozilla Maintenance Service on Windows
|
2023-11-05 22:17:12 +00:00
|
|
|
replace_line 'MOZ_MAINTENANCE_SERVICE:' 'MOZ_MAINTENANCE_SERVICE: false \&\&' modules/AppConstants.sys.mjs
|
2024-01-28 06:58:49 +00:00
|
|
|
# Continue using app.update.auto in prefs.js on Windows
|
2023-11-05 22:17:12 +00:00
|
|
|
replace_line 'PER_INSTALLATION_PREFS_PLATFORMS = \["win"\]' 'PER_INSTALLATION_PREFS_PLATFORMS = []' modules/UpdateUtils.sys.mjs
|
2023-05-20 11:22:22 +00:00
|
|
|
|
2023-05-04 12:39:23 +00:00
|
|
|
# Prompt if major update is available instead of installing automatically on restart
|
2023-04-23 07:57:55 +00:00
|
|
|
replace_line 'if \(!updateAuto\) \{' 'if (update.type == "major") {
|
|
|
|
LOG("UpdateService:_selectAndInstallUpdate - prompting because it is a major update");
|
|
|
|
AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_SHOWPROMPT_PREF);
|
|
|
|
Services.obs.notifyObservers(update, "update-available", "show-prompt");
|
|
|
|
return;
|
|
|
|
}
|
2023-11-05 22:17:12 +00:00
|
|
|
if (!updateAuto) {' modules/UpdateService.sys.mjs
|
2023-04-23 07:57:55 +00:00
|
|
|
|
2023-05-05 04:37:09 +00:00
|
|
|
# Avoid console warning about resource://gre/modules/FxAccountsCommon.js
|
2023-11-05 22:17:12 +00:00
|
|
|
replace_line 'const logins = this._data.logins;' 'const logins = this._data.logins; if (this._data.logins.length != -1) return;' modules/LoginStore.sys.mjs
|
2023-05-05 04:37:09 +00:00
|
|
|
|
2023-04-30 09:19:53 +00:00
|
|
|
# Prevent error during network requests
|
2023-11-05 22:17:12 +00:00
|
|
|
replace_line 'async lazyInit\(\) \{' 'async lazyInit() { if (this.features) return false;' modules/UrlClassifierExceptionListService.sys.mjs
|
2023-04-30 09:19:53 +00:00
|
|
|
|
2023-04-23 07:57:55 +00:00
|
|
|
replace_line 'pref\("network.captive-portal-service.enabled".+' 'pref("network.captive-portal-service.enabled", false);' greprefs.js
|
|
|
|
replace_line 'pref\("network.connectivity-service.enabled".+' 'pref("network.connectivity-service.enabled", false);' greprefs.js
|
|
|
|
replace_line 'pref\("toolkit.telemetry.server".+' 'pref("toolkit.telemetry.server", "");' greprefs.js
|
|
|
|
replace_line 'pref\("toolkit.telemetry.unified".+' 'pref("toolkit.telemetry.unified", false);' greprefs.js
|
2023-04-27 04:31:52 +00:00
|
|
|
replace_line 'pref\("media.gmp-manager.url".+' 'pref("media.gmp-manager.url", "");' greprefs.js
|
2023-04-23 07:57:55 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# # Disable transaction timeout
|
|
|
|
# perl -pi -e 's/let timeoutPromise/\/*let timeoutPromise/' modules/Sqlite.jsm
|
|
|
|
# perl -pi -e 's/return Promise.race\(\[transactionPromise, timeoutPromise\]\);/*\/return transactionPromise;/' modules/Sqlite.jsm
|
|
|
|
# rm -f jsloader/resource/gre/modules/Sqlite.jsm
|
|
|
|
#
|
|
|
|
# Disable unwanted components
|
|
|
|
remove_line '(RemoteSettings|services-|telemetry|Telemetry|URLDecorationAnnotationsService)' components/components.manifest
|
|
|
|
|
2024-04-08 05:45:00 +00:00
|
|
|
# Do not trigger LoginManager event that logs an error on autocomplete submission
|
|
|
|
remove_line 'DOMInputPasswordAdded: \{\},' modules/ActorManagerParent.sys.mjs
|
|
|
|
|
2024-03-31 10:25:30 +00:00
|
|
|
# On Mac/Linux, ignore relative paths in PATH in Subprocess.pathSearch(), used when a bare command is passed to Utilities.Internal.subprocess()
|
2024-03-31 10:28:51 +00:00
|
|
|
if [[ $platform != win* ]]; then
|
2024-03-31 10:25:30 +00:00
|
|
|
replace_line 'let path = PathUtils.join\(dir, bin\);' 'if (!dir.startsWith("\/")) continue; let path = PathUtils.join(dir, bin);' modules/subprocess/subprocess_unix.sys.mjs
|
|
|
|
fi
|
2024-03-31 09:09:40 +00:00
|
|
|
|
2023-04-23 07:57:55 +00:00
|
|
|
# Remove unwanted files
|
|
|
|
rm modules/FxAccounts*
|
|
|
|
# Causes a startup error -- try an empty file or a shim instead?
|
|
|
|
#rm modules/Telemetry*
|
2023-11-05 22:17:12 +00:00
|
|
|
rm modules/URLDecorationAnnotationsService.sys.mjs
|
2023-04-23 07:57:55 +00:00
|
|
|
rm -rf modules/services-*
|
|
|
|
|
|
|
|
# Clear most WebExtension manifest properties
|
|
|
|
replace_line 'manifest = normalized.value;' 'manifest = normalized.value;
|
|
|
|
if (this.type == "extension") {
|
|
|
|
if (!manifest.applications?.zotero?.id) {
|
|
|
|
this.manifestError("applications.zotero.id not provided");
|
|
|
|
}
|
|
|
|
if (!manifest.applications?.zotero?.update_url) {
|
|
|
|
this.manifestError("applications.zotero.update_url not provided");
|
|
|
|
}
|
|
|
|
if (!manifest.applications?.zotero?.strict_max_version) {
|
|
|
|
this.manifestError("applications.zotero.strict_max_version not provided");
|
|
|
|
}
|
|
|
|
manifest.browser_specific_settings = undefined;
|
|
|
|
manifest.content_scripts = [];
|
|
|
|
manifest.permissions = [];
|
|
|
|
manifest.host_permissions = [];
|
|
|
|
manifest.web_accessible_resources = undefined;
|
|
|
|
manifest.experiment_apis = {};
|
2023-11-05 22:17:12 +00:00
|
|
|
}' modules/Extension.sys.mjs
|
2023-04-23 07:57:55 +00:00
|
|
|
|
|
|
|
# Use applications.zotero instead of applications.gecko
|
|
|
|
replace_line 'let bss = manifest.applications\?.gecko' 'let bss = manifest.applications?.zotero' modules/addons/XPIInstall.jsm
|
2023-11-05 22:17:12 +00:00
|
|
|
replace_line 'manifest.applications\?.gecko' 'manifest.applications?.zotero' modules/Extension.sys.mjs
|
2023-04-23 07:57:55 +00:00
|
|
|
|
|
|
|
# When installing addon, use app version instead of toolkit version for targetApplication
|
|
|
|
replace_line "id: TOOLKIT_ID," "id: '$APP_ID'," modules/addons/XPIInstall.jsm
|
|
|
|
|
|
|
|
# Accept zotero@chnm.gmu.edu for target application to allow Zotero 6 plugins to remain
|
|
|
|
# installed in Zotero 7
|
|
|
|
replace_line "if \(targetApp.id == Services.appinfo.ID\) \{" "if (targetApp.id == 'zotero\@chnm.gmu.edu') targetApp.id = '$APP_ID'; if (targetApp.id == Services.appinfo.ID) {" modules/addons/XPIDatabase.jsm
|
2024-04-09 23:02:27 +00:00
|
|
|
|
|
|
|
# TEMP: Skip addons without ids until we figure out what's going on with the default theme.
|
|
|
|
# This fixes plugin updating and other things.
|
|
|
|
replace_line 'return addons;' 'return addons.filter(addon => addon.id);' modules/addons/XPIDatabase.jsm
|
2023-04-23 07:57:55 +00:00
|
|
|
|
|
|
|
# For updates, look for applications.zotero instead of applications.gecko in manifest.json and
|
|
|
|
# use the app id and version for strict_min_version/strict_max_version comparisons
|
2023-11-05 22:17:12 +00:00
|
|
|
replace_line 'gecko: \{\},' 'zotero: {},' modules/addons/AddonUpdateChecker.sys.mjs
|
|
|
|
replace_line 'if \(!\("gecko" in applications\)\) \{' 'if (!("zotero" in applications)) {' modules/addons/AddonUpdateChecker.sys.mjs
|
|
|
|
replace_line '"gecko not in application entry' '"zotero not in application entry' modules/addons/AddonUpdateChecker.sys.mjs
|
|
|
|
replace_line 'let app = getProperty\(applications, "gecko", "object"\);' 'let app = getProperty(applications, "zotero", "object");' modules/addons/AddonUpdateChecker.sys.mjs
|
|
|
|
replace_line "id: TOOLKIT_ID," "id: '$APP_ID'," modules/addons/AddonUpdateChecker.sys.mjs
|
2024-04-01 19:23:09 +00:00
|
|
|
replace_line 'lazy.AddonManagerPrivate.webExtensionsMinPlatformVersion' '"7.0"' modules/addons/AddonUpdateChecker.sys.mjs
|
2023-11-05 22:17:12 +00:00
|
|
|
replace_line 'result.targetApplications.push' 'false && result.targetApplications.push' modules/addons/AddonUpdateChecker.sys.mjs
|
2023-04-23 07:57:55 +00:00
|
|
|
|
|
|
|
# Allow addon installation by bypassing confirmation dialogs. If we want a confirmation dialog,
|
|
|
|
# we need to either add gXPInstallObserver from browser-addons.js [1][2] or provide our own with
|
|
|
|
# Ci.amIWebInstallPrompt [3].
|
|
|
|
#
|
|
|
|
# [1] https://searchfox.org/mozilla-esr102/rev/5a6d529652045050c5cdedc0558238949b113741/browser/base/content/browser.js#1902-1923
|
|
|
|
# [2] https://searchfox.org/mozilla-esr102/rev/5a6d529652045050c5cdedc0558238949b113741/browser/base/content/browser-addons.js#201
|
2023-11-05 22:17:12 +00:00
|
|
|
# [3] https://searchfox.org/mozilla-esr102/rev/5a6d529652045050c5cdedc0558238949b113741/toolkit/mozapps/extensions/AddonManager.sys.mjs#3114-3124
|
|
|
|
replace_line 'if \(info.addon.userPermissions\) \{' 'if (false) {' modules/AddonManager.sys.mjs
|
|
|
|
replace_line '\} else if \(info.addon.sitePermissions\) \{' '} else if (false) {' modules/AddonManager.sys.mjs
|
|
|
|
replace_line '\} else if \(requireConfirm\) \{' '} else if (false) {' modules/AddonManager.sys.mjs
|
2023-04-23 07:57:55 +00:00
|
|
|
|
2023-07-01 10:03:14 +00:00
|
|
|
# Make addon listener methods wait for promises, to allow calling asynchronous plugin `shutdown`
|
|
|
|
# and `uninstall` methods in our `onInstalling` handler
|
2023-11-05 22:17:12 +00:00
|
|
|
replace_line 'callAddonListeners\(aMethod' 'async callAddonListeners(aMethod' modules/AddonManager.sys.mjs
|
2023-07-01 10:03:14 +00:00
|
|
|
# Don't need this one to be async, but we can't easily avoid modifying its `listener[aMethod].apply()` call
|
2023-11-05 22:17:12 +00:00
|
|
|
replace_line 'callManagerListeners\(aMethod' 'async callManagerListeners(aMethod' modules/AddonManager.sys.mjs
|
2023-07-01 10:03:14 +00:00
|
|
|
replace_line 'AddonManagerInternal.callAddonListeners.apply\(AddonManagerInternal, aArgs\);' \
|
2023-11-05 22:17:12 +00:00
|
|
|
'return AddonManagerInternal.callAddonListeners.apply(AddonManagerInternal, aArgs);' modules/AddonManager.sys.mjs
|
2023-07-01 10:03:14 +00:00
|
|
|
replace_line 'listener\[aMethod\].apply\(listener, aArgs\);' \
|
|
|
|
'let maybePromise = listener[aMethod].apply(listener, aArgs);
|
2023-11-05 22:17:12 +00:00
|
|
|
if (maybePromise && maybePromise.then) await maybePromise;' modules/AddonManager.sys.mjs
|
2023-07-01 10:03:14 +00:00
|
|
|
replace_line 'AddonManagerPrivate.callAddonListeners' 'await AddonManagerPrivate.callAddonListeners' modules/addons/XPIInstall.jsm
|
|
|
|
replace_line 'let uninstall = \(\) => \{' 'let uninstall = async () => {' modules/addons/XPIInstall.jsm
|
|
|
|
replace_line 'cancelUninstallAddon\(aAddon\)' 'async cancelUninstallAddon(aAddon)' modules/addons/XPIInstall.jsm
|
|
|
|
|
2023-04-23 07:57:55 +00:00
|
|
|
# No idea why this is necessary, but without it initialization fails with "TypeError: "constructor" is read-only"
|
2023-11-05 22:17:12 +00:00
|
|
|
replace_line 'LoginStore.prototype.constructor = LoginStore;' '\/\/LoginStore.prototype.constructor = LoginStore;' modules/LoginStore.sys.mjs
|
2023-04-23 07:57:55 +00:00
|
|
|
#
|
|
|
|
# # Allow proxy password saving
|
|
|
|
# perl -pi -e 's/get _inPrivateBrowsing\(\) \{/get _inPrivateBrowsing() {if (true) { return false; }/' components/nsLoginManagerPrompter.js
|
|
|
|
#
|
|
|
|
# # Change text in update dialog
|
|
|
|
# perl -pi -e 's/A security and stability update for/A new version of/' chrome/en-US/locale/en-US/mozapps/update/updates.properties
|
|
|
|
# perl -pi -e 's/updateType_major=New Version/updateType_major=New Major Version/' chrome/en-US/locale/en-US/mozapps/update/updates.properties
|
|
|
|
# perl -pi -e 's/updateType_minor=Security Update/updateType_minor=New Version/' chrome/en-US/locale/en-US/mozapps/update/updates.properties
|
|
|
|
# perl -pi -e 's/update for &brandShortName; as soon as possible/update as soon as possible/' chrome/en-US/locale/en-US/mozapps/update/updates.dtd
|
|
|
|
#
|
|
|
|
# Set available locales
|
2023-04-29 09:49:55 +00:00
|
|
|
cp "$APP_ROOT_DIR/assets/multilocale.txt" res/multilocale.txt
|
2023-04-23 07:57:55 +00:00
|
|
|
|
|
|
|
# Use Zotero URL opening in Mozilla dialogs (e.g., app update dialog)
|
2023-11-06 06:26:47 +00:00
|
|
|
replace_line 'function openURL\(aURL\) \{' 'function openURL(aURL) {let {Zotero} = ChromeUtils.importESModule("chrome:\/\/zotero\/content\/zotero.mjs"); Zotero.launchURL(aURL); if (true) { return; }' chrome/toolkit/content/global/contentAreaUtils.js
|
2023-04-23 07:57:55 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Modify Add-ons window
|
|
|
|
#
|
2023-12-08 11:08:18 +00:00
|
|
|
|
|
|
|
# Prevent display: block from overriding display: none on <hr>s
|
|
|
|
replace_line 'display: block !important;' 'display: block;' chrome/toolkit/content/global/elements/panel-list.css
|
|
|
|
|
2023-04-23 07:57:55 +00:00
|
|
|
file="chrome/toolkit/content/mozapps/extensions/aboutaddons.css"
|
|
|
|
echo >> $file
|
|
|
|
# Hide search bar, Themes and Plugins tabs, and sidebar footer
|
|
|
|
echo '.main-search, button[name="theme"], button[name="plugin"], sidebar-footer { display: none; }' >> $file
|
|
|
|
echo '.main-heading { margin-top: 2em; }' >> $file
|
|
|
|
# Hide Details/Permissions tabs in addon details so we only show details
|
|
|
|
echo 'addon-details > button-group { display: none !important; }' >> $file
|
|
|
|
# Hide "Debug Addons" and "Manage Extension Shortcuts"
|
2023-12-08 11:08:18 +00:00
|
|
|
echo 'panel-item[action="debug-addons"], panel-item[action="reset-update-states"] + hr, panel-item[action="manage-shortcuts"] { display: none }' >> $file
|
2024-03-30 08:56:03 +00:00
|
|
|
# Show cursor feedback on plugin homepage links
|
|
|
|
echo '.addon-detail-row-homepage .text-link { cursor: pointer; color: -moz-nativehyperlinktext; }' >> $file
|
|
|
|
echo '.addon-detail-row-homepage .text-link:hover { text-decoration: underline; }' >> $file
|
2023-04-23 07:57:55 +00:00
|
|
|
|
|
|
|
file="chrome/toolkit/content/mozapps/extensions/aboutaddons.js"
|
|
|
|
# Hide unsigned-addon warning
|
|
|
|
replace_line 'if \(!isCorrectlySigned\(addon\)\) \{' 'if (!isCorrectlySigned(addon)) {return {};' $file
|
|
|
|
# Hide Private Browsing setting in addon details
|
|
|
|
replace_line 'pbRow\.' '\/\/pbRow.' $file
|
|
|
|
replace_line 'let isAllowed = await isAllowedInPrivateBrowsing' '\/\/let isAllowed = await isAllowedInPrivateBrowsing' $file
|
|
|
|
# Use our own strings for the removal prompt
|
|
|
|
replace_line 'let \{ BrowserAddonUI \} = windowRoot.ownerGlobal;' '' $file
|
|
|
|
replace_line 'await BrowserAddonUI.promptRemoveExtension' 'promptRemoveExtension' $file
|
|
|
|
|
|
|
|
# Customize empty-list message
|
|
|
|
replace_line 'createEmptyListMessage\(\) {' 'createEmptyListMessage() {
|
|
|
|
var p = document.createElement("p");
|
|
|
|
p.id = "empty-list-message";
|
|
|
|
return p;' $file
|
|
|
|
# Swap in include.js, which we need for Zotero.getString(), for abuse-reports.js, which we don't need
|
|
|
|
|
2024-03-11 06:19:09 +00:00
|
|
|
# Open plugin links in external browser
|
|
|
|
replace_line 'let homepageURL = homepageRow.querySelector\(\"a\"\);' 'let homepageURL = homepageRow.querySelector(\"\.text-link\");' $file
|
|
|
|
replace_line 'homepageURL.href = addon.homepageURL;' 'homepageURL.setAttribute("href", addon.homepageURL);' $file
|
2024-03-30 08:55:36 +00:00
|
|
|
replace_line '<a target="_blank" dir="ltr"><\/a>' \
|
|
|
|
'<label target="_blank" class="text-link" dir="ltr"><\/label>' \
|
2024-03-11 06:19:09 +00:00
|
|
|
chrome/toolkit/content/mozapps/extensions/aboutaddons.html
|
|
|
|
|
2023-04-23 07:57:55 +00:00
|
|
|
# Hide Recommendations tab in sidebar and recommendations in main pane
|
|
|
|
replace_line 'function isDiscoverEnabled\(\) \{' 'function isDiscoverEnabled() {return false;' chrome/toolkit/content/mozapps/extensions/aboutaddonsCommon.js
|
|
|
|
replace_line 'pref\("extensions.htmlaboutaddons.recommendations.enabled".+' 'pref("extensions.htmlaboutaddons.recommendations.enabled", false);' greprefs.js
|
|
|
|
|
|
|
|
# Hide Report option
|
|
|
|
replace_line 'pref\("extensions.abuseReport.enabled".+' 'pref("extensions.abuseReport.enabled", false);' greprefs.js
|
|
|
|
|
|
|
|
# The first displayed Services.prompt dialog's size jumps around because sizeToContent() is called twice
|
|
|
|
# Fix by preventing the first sizeToContent() call if the icon hasn't been loaded yet
|
|
|
|
replace_line 'window.sizeToContent\(\);' 'if (ui.infoIcon.complete) window.sizeToContent();' chrome/toolkit/content/global/commonDialog.js
|
|
|
|
replace_line 'ui.infoIcon.addEventListener' 'if (!ui.infoIcon.complete) ui.infoIcon.addEventListener' chrome/toolkit/content/global/commonDialog.js
|
|
|
|
|
2024-03-02 07:51:55 +00:00
|
|
|
# Import style into built-in dialogs
|
2024-03-02 12:09:13 +00:00
|
|
|
replace_line 'id=\"commonDialogWindow\"' \
|
2024-04-19 11:32:50 +00:00
|
|
|
'id=\"commonDialogWindow\" class=\"zotero-dialog\" drawintitlebar-platforms=\"mac\"' \
|
2024-03-02 07:51:55 +00:00
|
|
|
chrome/toolkit/content/global/commonDialog.xhtml
|
|
|
|
replace_line '<\?xml-stylesheet href=\"chrome:\/\/global\/skin\/commonDialog.css\" type=\"text\/css\"\?>' \
|
|
|
|
'<\?xml-stylesheet href=\"chrome:\/\/global\/skin\/commonDialog.css\" type=\"text\/css\"\?>
|
|
|
|
<\?xml-stylesheet href=\"chrome:\/\/zotero-platform\/content\/zotero.css\" type=\"text\/css\"\?>' \
|
|
|
|
chrome/toolkit/content/global/commonDialog.xhtml
|
2024-04-02 05:07:40 +00:00
|
|
|
# commonDialog.xhtml can be opened via Services.prompt in the Profile Manager, so check for a profile first
|
2024-03-02 07:51:55 +00:00
|
|
|
replace_line '<script>' \
|
|
|
|
'<script>
|
2024-04-02 05:07:40 +00:00
|
|
|
try {
|
|
|
|
Services.dirsvc.get(\"ProfD\", Ci.nsIFile);
|
|
|
|
Services.scriptloader.loadSubScript(\"chrome:\/\/zotero\/content\/include.js\", this);
|
2024-04-19 11:32:50 +00:00
|
|
|
Services.scriptloader.loadSubScript(\"chrome:\/\/zotero\/content\/titlebar.js\", this);
|
2024-04-02 05:07:40 +00:00
|
|
|
Services.scriptloader.loadSubScript(\"chrome:\/\/zotero\/content\/customElements.js\", this);
|
|
|
|
} catch (e) {}' \
|
2024-03-02 07:51:55 +00:00
|
|
|
chrome/toolkit/content/global/commonDialog.xhtml
|
|
|
|
|
2023-04-23 07:57:55 +00:00
|
|
|
# Use native checkbox instead of Firefox-themed version in prompt dialogs
|
|
|
|
replace_line '<xul:checkbox' '<xul:checkbox native=\"true\"' chrome/toolkit/content/global/commonDialog.xhtml
|
|
|
|
|
2023-06-28 17:08:59 +00:00
|
|
|
# The <browser> CE appends its autoscroll <popup> to document.documentElement, which doesn't work in zoteroPane.xhtml
|
|
|
|
# (in Firefox browser.xhtml, document.documentElement is <html>, which can contain <popup>s; in zoteroPane.xhtml, it's
|
|
|
|
# <window>, which can't)
|
|
|
|
# Fix by appending it to a <popupset> instead
|
|
|
|
replace_line 'document.documentElement.appendChild\(this._autoScrollPopup\);' 'let popupset = document.querySelector("popupset");
|
|
|
|
if (!popupset) {
|
|
|
|
popupset = document.createXULElement("popupset");
|
|
|
|
document.documentElement.appendChild(popupset);
|
|
|
|
}
|
|
|
|
popupset.appendChild(this._autoScrollPopup);' chrome/toolkit/content/global/elements/browser-custom-element.js
|
|
|
|
|
2024-04-19 11:04:42 +00:00
|
|
|
# Show Services menu on input fields
|
|
|
|
# (JS part of https://hg.mozilla.org/mozilla-central/rev/defc298879844981e7c1817f13e3fc2caf84f148 for input boxes)
|
|
|
|
replace_line '<menupopup class="textbox-contextmenu">' '<menupopup class="textbox-contextmenu" showservicesmenu="true">' chrome/toolkit/content/global/elements/moz-input-box.js
|
|
|
|
|
2023-04-23 07:57:55 +00:00
|
|
|
zip -qr9XD omni.ja *
|
|
|
|
mv omni.ja ..
|
|
|
|
cd ..
|
2023-04-29 09:49:55 +00:00
|
|
|
python3 "$APP_ROOT_DIR/scripts/optimizejars.py" --optimize ./ ./ ./
|
2023-04-23 07:57:55 +00:00
|
|
|
rm -rf omni
|
|
|
|
|
|
|
|
# Unzip browser/omni.ja and leave unzipped
|
|
|
|
cd browser
|
|
|
|
mkdir omni
|
|
|
|
mv omni.ja omni
|
|
|
|
cd omni
|
|
|
|
ls -la
|
|
|
|
set +e
|
|
|
|
unzip omni.ja
|
|
|
|
set -e
|
|
|
|
rm omni.ja
|
|
|
|
|
|
|
|
# Remove Firefox update URLs
|
|
|
|
remove_line 'pref\("app.update.url.(manual|details)' defaults/preferences/firefox-branding.js
|
|
|
|
|
|
|
|
# Remove Firefox overrides (e.g., to use Firefox-specific strings for connection errors)
|
|
|
|
remove_line '(override)' chrome/chrome.manifest
|
|
|
|
|
|
|
|
# Remove WebExtension APIs
|
|
|
|
remove_line ext-browser.json components/components.manifest
|
2023-05-24 06:21:24 +00:00
|
|
|
|
|
|
|
# Don't open a second window if app is already open when launching .exe (Windows) or running via
|
|
|
|
# command line (macOS)
|
|
|
|
replace_line 'function dch_handle\(cmdLine\) \{' 'function dch_handle(cmdLine) {
|
|
|
|
if (cmdLine.state == Ci.nsICommandLine.STATE_REMOTE_AUTO) { return; }
|
2023-11-05 22:17:12 +00:00
|
|
|
' modules/BrowserContentHandler.sys.mjs
|
2023-04-23 07:57:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mkdir -p xulrunner
|
|
|
|
cd xulrunner
|
|
|
|
|
|
|
|
if [ $BUILD_MAC == 1 ]; then
|
|
|
|
GECKO_VERSION="$GECKO_VERSION_MAC"
|
|
|
|
DOWNLOAD_URL="https://ftp.mozilla.org/pub/firefox/releases/$GECKO_VERSION"
|
|
|
|
rm -rf Firefox.app
|
|
|
|
|
|
|
|
if [ -e "Firefox $GECKO_VERSION.app.zip" ]; then
|
|
|
|
echo "Using Firefox $GECKO_VERSION.app.zip"
|
|
|
|
unzip "Firefox $GECKO_VERSION.app.zip"
|
|
|
|
else
|
|
|
|
curl -o Firefox.dmg "$DOWNLOAD_URL/mac/en-US/Firefox%20$GECKO_VERSION.dmg"
|
|
|
|
set +e
|
|
|
|
hdiutil detach -quiet /Volumes/Firefox 2>/dev/null
|
|
|
|
set -e
|
|
|
|
hdiutil attach -quiet Firefox.dmg
|
|
|
|
cp -a /Volumes/Firefox/Firefox.app .
|
|
|
|
hdiutil detach -quiet /Volumes/Firefox
|
|
|
|
fi
|
|
|
|
|
2024-04-19 11:04:42 +00:00
|
|
|
# Download custom components (e.g., XUL), as an xz-compressed tarball of the MacOS folder with
|
|
|
|
# custom files in it
|
|
|
|
echo
|
|
|
|
rm -rf MacOS
|
|
|
|
if [ -n "$custom_components_hash_mac" ]; then
|
|
|
|
if [ -e "Firefox $GECKO_VERSION MacOS.zip" ]; then
|
|
|
|
echo "Using Firefox $GECKO_VERSION MacOS.zip"
|
|
|
|
unzip "Firefox $GECKO_VERSION MacOS.zip"
|
|
|
|
else
|
|
|
|
echo "Downloading custom Firefox components"
|
|
|
|
echo
|
|
|
|
curl -o MacOS.tar.xz "${custom_components_url}mac/$custom_components_hash_mac.tar.xz"
|
|
|
|
|
|
|
|
# Verify hash
|
|
|
|
if [[ "`uname`" = "Darwin" ]]; then
|
|
|
|
shasum=sha256sum
|
|
|
|
else
|
|
|
|
shasum=shasum
|
|
|
|
fi
|
|
|
|
echo
|
|
|
|
echo "$custom_components_hash_mac MacOS.tar.xz" | $shasum -c -
|
|
|
|
echo
|
|
|
|
|
|
|
|
tar xvf MacOS.tar.xz
|
|
|
|
fi
|
|
|
|
echo
|
|
|
|
fi
|
2023-04-23 07:57:55 +00:00
|
|
|
|
|
|
|
pushd Firefox.app/Contents/Resources
|
|
|
|
modify_omni mac
|
|
|
|
popd
|
|
|
|
|
2023-05-26 10:43:15 +00:00
|
|
|
# Replace "FirefoxCP" with "ZoteroCP" for subprocesses ("Isolated Web Content", "Socket Process", "Web Content", etc.)
|
|
|
|
info_plist=Firefox.app/Contents/MacOS/plugin-container.app/Contents/Resources/English.lproj/InfoPlist.strings
|
|
|
|
from=$(get_utf16_chars "FirefoxCP")
|
|
|
|
to=$(get_utf16_chars "ZoteroCP")
|
|
|
|
perl -pi -e "s/$from/$to/" $info_plist
|
|
|
|
# Check for UTF-16 "ZoteroCP"
|
|
|
|
if ! grep -a -q "Z.o.t.e.r.o.C.P." $info_plist; then
|
|
|
|
echo '"ZoteroCP" not found in InfoPlist.strings after replacement'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-04-23 07:57:55 +00:00
|
|
|
if [ ! -e "Firefox $GECKO_VERSION.app.zip" ]; then
|
|
|
|
rm "Firefox.dmg"
|
|
|
|
fi
|
|
|
|
|
|
|
|
#if [ ! -e "Firefox $GECKO_VERSION MacOS.zip" ]; then
|
|
|
|
# rm "MacOS.zip"
|
|
|
|
#fi
|
2023-07-05 12:01:32 +00:00
|
|
|
echo $("$SCRIPT_DIR/xulrunner_hash" -p m) > hash-mac
|
2023-04-23 07:57:55 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $BUILD_WIN == 1 ]; then
|
|
|
|
GECKO_VERSION="$GECKO_VERSION_WIN"
|
|
|
|
DOWNLOAD_URL="https://ftp.mozilla.org/pub/firefox/releases/$GECKO_VERSION"
|
|
|
|
|
2024-04-06 08:50:04 +00:00
|
|
|
for arch in win32 win-x64 win-aarch64; do
|
2023-04-23 07:57:55 +00:00
|
|
|
xdir=firefox-$arch
|
|
|
|
|
|
|
|
rm -rf $xdir
|
|
|
|
mkdir $xdir
|
|
|
|
|
2023-05-20 11:34:24 +00:00
|
|
|
if [ -e "Firefox Setup $GECKO_VERSION-$arch.exe" ]; then
|
|
|
|
echo "Using Firefox Setup $GECKO_VERSION-$arch.exe"
|
|
|
|
cp "Firefox Setup $GECKO_VERSION-$arch.exe" "Firefox%20Setup%20$GECKO_VERSION.exe"
|
2023-05-11 04:17:12 +00:00
|
|
|
else
|
2023-05-20 11:34:24 +00:00
|
|
|
if [ $arch = "win-x64" ]; then
|
|
|
|
curl -O "$DOWNLOAD_URL/win64/en-US/Firefox%20Setup%20$GECKO_VERSION.exe"
|
2024-04-06 08:50:04 +00:00
|
|
|
elif [ $arch = "win-aarch64" ]; then
|
|
|
|
curl -O "$DOWNLOAD_URL/win64-aarch64/en-US/Firefox%20Setup%20$GECKO_VERSION.exe"
|
2023-05-20 11:34:24 +00:00
|
|
|
else
|
|
|
|
curl -O "$DOWNLOAD_URL/$arch/en-US/Firefox%20Setup%20$GECKO_VERSION.exe"
|
|
|
|
fi
|
2023-05-11 04:17:12 +00:00
|
|
|
fi
|
2023-04-23 07:57:55 +00:00
|
|
|
|
|
|
|
7z x Firefox%20Setup%20$GECKO_VERSION.exe -o$xdir 'core/*'
|
|
|
|
mv $xdir/core $xdir-core
|
|
|
|
rm -rf $xdir
|
|
|
|
mv $xdir-core $xdir
|
|
|
|
|
|
|
|
pushd $xdir
|
2023-05-20 11:31:39 +00:00
|
|
|
|
|
|
|
# Replace "Mozilla-1de4eec8-1241-4177-a864-e594e8d1fb38" with "Zotero" for C:\ProgramData directory
|
|
|
|
#
|
|
|
|
# Mozilla uses a UUID in the path because they previously used just "Mozilla" and needed to
|
|
|
|
# recreate the folder with correct permissions for security reasons, but we never had a folder in
|
|
|
|
# ProgramData, so we can just create it as "Zotero". Instead of using a custom xul.dll, just
|
|
|
|
# replace the hard-coded string with "Zotero" and add a bunch of NULs.
|
2023-05-26 10:43:46 +00:00
|
|
|
from=$(get_utf16_chars "Mozilla-1de4eec8-1241-4177-a864-e594e8d1fb38")
|
|
|
|
to=$(get_utf16_chars "Zotero" 38)
|
|
|
|
perl -pe "s/$from/$to/" < xul.dll > xul.dll.new
|
2023-05-20 11:31:39 +00:00
|
|
|
mv xul.dll.new xul.dll
|
2023-05-22 12:18:49 +00:00
|
|
|
|
|
|
|
# Check for UTF-16 "Zotero" in DLL
|
|
|
|
#
|
|
|
|
# (The macOS strings command doesn't have an encoding option, so skip on macOS. We could
|
|
|
|
# require binutils, which has GNU strings, but you need to build on Windows to make an
|
|
|
|
# installer, so a Windows build from macOS likely isn't being deployed, and there's no
|
|
|
|
# reason the Perl command above should fail anyway.)
|
2023-05-24 07:29:43 +00:00
|
|
|
if [[ "`uname`" != "Darwin" ]] && [[ -z "$(strings -e l xul.dll | grep -m 1 Zotero)" ]]; then
|
2023-05-20 11:31:39 +00:00
|
|
|
echo '"Zotero" not found in xul.dll after replacement'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-04-23 07:57:55 +00:00
|
|
|
modify_omni $arch
|
2023-06-28 11:27:18 +00:00
|
|
|
# Disable skeleton UI window
|
|
|
|
# https://forums.zotero.org/discussion/comment/437636/#Comment_437636
|
|
|
|
replace_line 'pref\("browser\.startup\.preXulSkeletonUI", true\);' 'pref("browser.startup.preXulSkeletonUI", false);' defaults/preferences/firefox.js
|
2023-04-23 07:57:55 +00:00
|
|
|
popd
|
|
|
|
|
2023-05-24 03:42:58 +00:00
|
|
|
# Uncomment to create local copies for reuse
|
|
|
|
#cp "Firefox%20Setup%20$GECKO_VERSION.exe" "Firefox Setup $GECKO_VERSION-$arch.exe"
|
2023-04-23 07:57:55 +00:00
|
|
|
rm "Firefox%20Setup%20$GECKO_VERSION.exe"
|
|
|
|
echo
|
|
|
|
echo
|
|
|
|
done
|
2023-07-05 12:01:32 +00:00
|
|
|
echo $("$SCRIPT_DIR/xulrunner_hash" -p w) > hash-win
|
2023-04-23 07:57:55 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $BUILD_LINUX == 1 ]; then
|
|
|
|
GECKO_VERSION="$GECKO_VERSION_LINUX"
|
|
|
|
DOWNLOAD_URL="https://ftp.mozilla.org/pub/firefox/releases/$GECKO_VERSION"
|
2023-07-06 22:43:57 +00:00
|
|
|
|
|
|
|
|
2023-04-30 10:08:16 +00:00
|
|
|
# Include 32-bit build if not in CI
|
2023-07-06 22:43:57 +00:00
|
|
|
if [[ "${CI:-}" = "1" ]] || [[ "${SKIP_32:-}" = "1" ]]; then
|
|
|
|
arches="x86_64"
|
|
|
|
else
|
|
|
|
arches="i686 x86_64"
|
|
|
|
fi
|
|
|
|
for arch in $arches; do
|
|
|
|
xdir="firefox-$arch"
|
|
|
|
rm -rf $xdir
|
2023-04-30 10:08:16 +00:00
|
|
|
|
2023-07-06 22:43:57 +00:00
|
|
|
archived_file="firefox-$GECKO_VERSION-$arch.tar.bz2"
|
|
|
|
if [ -e "$archived_file" ]; then
|
|
|
|
echo "Using $archived_file"
|
|
|
|
cp "$archived_file" "firefox-$GECKO_VERSION.tar.bz2"
|
|
|
|
else
|
|
|
|
curl -O "$DOWNLOAD_URL/linux-$arch/en-US/firefox-$GECKO_VERSION.tar.bz2"
|
|
|
|
fi
|
|
|
|
|
|
|
|
tar xvf firefox-$GECKO_VERSION.tar.bz2
|
|
|
|
mv firefox firefox-$arch
|
|
|
|
|
|
|
|
pushd firefox-$arch
|
2024-03-31 10:28:51 +00:00
|
|
|
modify_omni $arch
|
2023-04-30 10:08:16 +00:00
|
|
|
popd
|
2023-07-06 22:43:57 +00:00
|
|
|
echo $($SCRIPT_DIR/xulrunner_hash -p l) > hash-linux
|
2023-04-30 10:08:16 +00:00
|
|
|
rm "firefox-$GECKO_VERSION.tar.bz2"
|
2023-07-06 22:43:57 +00:00
|
|
|
done
|
2023-04-23 07:57:55 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo Done
|