I want to install chrome extensions in chrome browser through Terminal instead of doing in GUI. Is there any way to install the extensions from Terminal?
-
Related: https://stackoverflow.com/questions/16800696/how-install-crx-chrome-extension-via-command-line Related for Chromium: https://superuser.com/questions/528551/how-to-install-extensions-on-chromium-without-the-web-store – Ciro Santilli OurBigBook.com Jun 07 '21 at 12:36
3 Answers
Here is the script, you gonna need extension ids, they can be found in the address bar when you go to the details of the extension on the market or at chrome://extensions. The script will also install chrome if it is not installed, remove the middle part if that's not needed.
Save this script to the
install-chrome.shfile:#!/bin/bash install_chrome_extension () { preferences_dir_path="/opt/google/chrome/extensions" pref_file_path="$preferences_dir_path/$1.json" upd_url="https://clients2.google.com/service/update2/crx" mkdir -p "$preferences_dir_path" echo "{" > "$pref_file_path" echo " \"external_update_url\": \"$upd_url\"" >> "$pref_file_path" echo "}" >> "$pref_file_path" echo Added \""$pref_file_path"\" ["$2"] } if ! which "google-chrome" ; then wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub \ | sudo apt-key add - echo 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main' \ | sudo tee /etc/apt/sources.list.d/google-chrome.list sudo apt-get update sudo apt install google-chrome-stable else echo Chrome already installed fi install_chrome_extension "cfhdojbkjhnklbpkdaibdccddilifddb" "adblock plus" install_chrome_extension "fmkadmapgofadopljbjfkapdkoienihi" "react dev tools" install_chrome_extension "anmidgajdonkgmmilbccfefkfieajakd" "save pinned tabs" install_chrome_extension "dbepggeogbaibhgnhhndojpepiihcmeb" "vimium"Run
sudo bash install-chrome.shRestart chrome.
More scripts at https://github.com/grabantot/scripts
-
1You could simplify those three
echos greatly withprintf:printf '{\n "external_update_url": "%s"\n}\n' "$upd_url" > "$pref_file_path"– wjandrea Mar 10 '19 at 19:55 -
@grabantot Is there any way so that the startup page for adblocker can be avoided? – Jishan Dec 03 '19 at 20:23
-
Hi, thanks for your sharing, I have a question, can the script install the plugins to a specific Google account? If I open 2 browsers, one is using account1, and the other is using account2, how does the script know in which browser the extensions should install? – skyline May 23 '21 at 16:19
-
This process only work one time.... if the user goes on google chrome, click to remove the extension, and later HIMSELF decides to reinstall the extension using this script... it wont work... is there a way to make this process work across multiple reinstallations? – Rafael Lima Jul 06 '24 at 13:02
As in Google Chrome Documentations
Alternative extension installation methods : Using a preferences JSON file
requirements:
- Extension's ID
- latest Google Chrome install
here a script example (run with root privileges):
#!/usr/bin/bash
install extensions via terminal
fill the array with the needed extensions
key=["extension_name"] value="extension_ID"
declare -A EXTlist=(
["google-translate"]="aapbdbdomjkkjkaonfhkkikfgjllcleb"
["save-to-google-drive"]="gmbmikajjgmnabiglmofipeabaddhgne"
)
mkdir -p /opt/google/chrome/extensions
for i in "${!EXTlist[@]}"; do
# echo "Key: $i value: ${EXTlist[$i]}"
echo '{"external_update_url": "https://clients2.google.com/service/update2/crx"}' > /opt/google/chrome/extensions/${EXTlist[$i]}.json
done
- close and reopen chrome and you will find the chosen extensions on all profiles
- remember to use the flag
--no-first-runif you want to avoid the extensions first run pop ups
For Linux the extension get stored under : /opt/google/chrome/extensions/
For install a Chrome extension (unpacked), use this command in terminal;
<path to chrome> --load-extension=<path to extension directory>
-
3Hi @Akhil thanks for your response, can you please give an example with the proper commands.
Because am unable to find /opt/google/chrome/extensions/
– Rajendra Aug 08 '18 at 21:48