Skip to content

Instantly share code, notes, and snippets.

@pjv
Created June 7, 2017 12:35
Show Gist options
  • Save pjv/617f774dec75cc06dc7476f3ea21a3b5 to your computer and use it in GitHub Desktop.
Save pjv/617f774dec75cc06dc7476f3ea21a3b5 to your computer and use it in GitHub Desktop.
get latest version of installed ungoogled chromium extensions
#!/usr/bin/env bash
# dependencies:
# https://www.npmjs.com/package/chrome-web-store-item-property-cli
# https://stedolan.github.io/jq/
# curl
# configure these:
EXTENSIONS_DIR="/path/to/Chromium/Profile/Extensions" ## e.g. on macos ~/Library/Application Support/Chromium/Profile 1/Extensions
DOWNLOAD_DIR="/path/to/where/you/want/latest/extensions"
######################################################################################
CURDIR=`pwd`
cd $DOWNLOAD_DIR
for f in "$EXTENSIONS_DIR"/*; do
ID=${f##*/}
JSON=$(chrome-web-store-item-property $ID)
NAME=$(echo $JSON | jq -r '.name')
VERSION=$(echo $JSON | jq -r '.version')
URL="https://clients2.google.com/service/update2/crx?response=redirect&prodversion=48.0&x=id%3D$ID%26installsource%3Dondemand%26uc"
curl -s -L "$URL" > "$NAME-$VERSION.crx"
done
cd "$CURDIR"
@Birch-san
Copy link

Here's how to fill in prodversion:

CHROMVER=$(/usr/libexec/PlistBuddy -c 'print CFBundleShortVersionString' /Applications/Chromium.app/Contents/Info.plist)
MAJVER=$(awk -F. '{printf "%d.%d",$1,$2}' <<< "$CHROMVER")

@Birch-san
Copy link

Here's a new version which automatically compares your installed versions with remote versions, and downloads only newer extensions.

https://gist.github.com/Birch-san/a0d64dd9fd04ea2252eb362fcd3fc0e2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment