Forked from pjv/update_ungoogled_chromium_extensions.sh
Created
May 30, 2018 15:35
-
-
Save Birch-san/a0d64dd9fd04ea2252eb362fcd3fc0e2 to your computer and use it in GitHub Desktop.
get latest version of installed ungoogled chromium extensions
This file contains hidden or 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
#!/usr/bin/env bash | |
# dependencies: | |
# https://www.npmjs.com/package/chrome-web-store-item-property-cli | |
# https://stedolan.github.io/jq/ | |
# curl | |
# Ascertain directory in which script lives; compatible with all UNIX | |
# Thanks to kenorb | |
# http://stackoverflow.com/a/17744637/5257399 | |
MYDIR=$(cd -P -- "$(dirname -- "$0")" && pwd -P) | |
# configure these: | |
EXTENSIONS_DIR=~/"Library/Application Support/Chromium/Default/Extensions" ## e.g. on macos ~/Library/Application Support/Chromium/Profile 1/Extensions | |
DOWNLOAD_DIR="$MYDIR" | |
###################################################################################### | |
CHROMVER=$(/usr/libexec/PlistBuddy -c 'print CFBundleShortVersionString' /Applications/Chromium.app/Contents/Info.plist) | |
MAJVER=$(awk -F. '{printf "%d.%d",$1,$2}' <<< "$CHROMVER") | |
for f in "$EXTENSIONS_DIR"/*; do | |
ID="${f##*/}" | |
if [[ "$ID" == "Temp" ]]; then | |
continue | |
fi | |
JSON=$(chrome-web-store-item-property "$ID") | |
NAME=$(jq -r '.name' <<< "$JSON") | |
VERSION=$(jq -r '.version' <<< "$JSON") | |
EXISTINGVERPATH=( "$f"/* ) | |
EXISTINGVER=("${EXISTINGVERPATH[@]##*/}") | |
NEWESTPATH="${EXISTINGVERPATH[@]: -1}" | |
NEWESTVER="${NEWESTPATH##*/}" | |
NEWESTVERWITHOUTTRAILINGDIGIT="${NEWESTVER%_*}" | |
# WITHOUTTRAILINGDIGIT=("${EXISTINGVER[@]/%_*}") | |
# WITHOUTTRAILINGDIGIT | |
echo " | |
$NAME | |
newest version available: | |
$VERSION | |
existing installed versions: | |
${EXISTINGVER[@]} | |
newest installed version (alphabetically): | |
$NEWESTVERWITHOUTTRAILINGDIGIT | |
" | |
if [[ "$NEWESTVERWITHOUTTRAILINGDIGIT" == "$VERSION" ]]; then | |
echo "Skipping download of $NAME; you already have version '$EXISTINGVER', which is probably the same." | |
continue | |
fi | |
URL="https://clients2.google.com/service/update2/crx?response=redirect&prodversion=$MAJVER&x=id%3D$ID%26installsource%3Dondemand%26uc" | |
curl -s -L "$URL" > "$DOWNLOAD_DIR/$NAME-$VERSION.crx" | |
done | |
echo 'now go to: | |
chrome://extensions | |
and drag-and-drop in the downloaded extensions. | |
' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment