Created
March 19, 2019 14:11
-
-
Save pirpyn/3c62d94dd7ad9ddb7c403ec7fb0c4228 to your computer and use it in GitHub Desktop.
Allows to install an addon when firefox.cfg doesn't allow to ( :O )
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
# https://askubuntu.com/questions/73474/how-to-install-firefox-addon-from-command-line-in-scripts | |
scriptname=$(basename $(readlink -f $0)) | |
usage() { cat << EOF | |
usage: $scriptname url | |
Installe en local l'addon .xpi dispo à l'adresse url | |
exemples: | |
$scriptname https://www.zotero.org/download/connector/dl?browser=firefox&version=5.0.54 | |
$scriptname https://addons.mozilla.org/firefox/downloads/file/1709472/ublock_origin-1.18.6-an+fx.xpi?src=search | |
EOF | |
} | |
if [[ $# -ne 1 ]]; then | |
usage | |
exit 1 | |
fi | |
url=$1 | |
tmp="$(mktemp -d)" | |
echo "Downloading in $tmp ..." | |
addonfile="$tmp/addons.xpi" | |
wget -qO "$addonfile" $url | |
unzip -q -d $tmp $addonfile manifest.json | |
ID=$(awk -F '"' '/^ +"id":/ {print $4}' "$tmp/manifest.json") | |
echo "Addon ID: $ID" | |
firefoxaddonfile=$(ls -d ~/.mozilla/firefox/*.default/)extensions/$ID.xpi | |
if [[ ! -f "$firefoxaddonfile" ]]; then | |
mv "$addonfile" "$firefoxaddonfile" | |
echo "Addon installé dans: $firefoxaddonfile." | |
echo "Pensez à le désactiver puis à le réactiver pour l'installer complétement" | |
else | |
echo "Un addon existe déjà: $firefoxaddonfile. Abandon" | |
fi | |
echo "Suppression de $tmp" | |
rm -rf $tmp | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment