Skip to content

Instantly share code, notes, and snippets.

@cezaraugusto
Created June 10, 2024 14:16
Show Gist options
  • Save cezaraugusto/0101d2cb251c088f398ca0f8d4495ca0 to your computer and use it in GitHub Desktop.
Save cezaraugusto/0101d2cb251c088f398ca0f8d4495ca0 to your computer and use it in GitHub Desktop.
Install a Chrome extension from the command line (macOS)
#!/bin/bash
# https://developer.chrome.com/docs/extensions/mv3/external_extensions/#preferences
install_chrome_extension() {
chrome_extensions_folder="/Library/Application Support/Google/Chrome/External Extensions"
chrome_extensions_preferences_file="$chrome_extensions_folder/$1.json"
# This URL is used by Chrome to check for updates to external extensions
update_services_url="https://clients2.google.com/service/update2/crx"
mkdir -p "$chrome_extensions_folder"
echo "{" > "$chrome_extensions_preferences_file"
echo " \"external_update_url\": \"$update_services_url\"" >> "$chrome_extensions_preferences_file"
echo "}" >> "$chrome_extensions_preferences_file"
echo "Added \"$chrome_extensions_preferences_file\""
}
if [ $# -ne 1 ]; then
echo "Usage: $0 <extension_id>"
exit 1
fi
install_chrome_extension "$1"
# Usage:
# ./install_extension.sh <extension_id>
# Sample: adding React Dev Tools from command-line to Chrome
# ./install_extension.sh fmkadmapgofadopljbjfkapdkoienihi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment