Created
February 11, 2019 09:12
-
-
Save rlanyi/690486d1c99a0185087de92a493488ae to your computer and use it in GitHub Desktop.
Check if newer version of a Chrome extension is available in the Webstore and send notification to Slack
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
#!/bin/bash | |
# Use this script from cron to check if newer version of a Chrome extension is available and send notification to Slack | |
# Requirements: curl, jq, unzip | |
# Author: rlanyi | |
if [ "$#" -ne 3 ]; then | |
echo "Usage: ./versioncheck.sh <extension_id> <version> <slack_webhook_url>" | |
echo | |
echo "<extension_id> Chrome Webstore extension id (32 chars)" | |
echo "<version> version to compare to" | |
echo "<slack_webhook_url> Slack notification target URL on version change" | |
exit | |
fi | |
extension_id="$1" | |
base_version="$2" | |
webhook_url="$3" | |
rm /tmp/${extension_id}.zip 2> /dev/null | |
curl -s -L -o /tmp/${extension_id}.zip "https://clients2.google.com/service/update2/crx?response=redirect&os=linux&arch=x86-64&os_arch=x86-64&nacl_arch=x86-64&prod=chromiumcrx&prodchannel=unknown&prodversion=67.0.3396.79&acceptformat=crx2,crx3&x=id%3D${extension_id}%26uc" | |
version=$(unzip -q -c /tmp/${extension_id}.zip manifest.json 2> /dev/null | jq -r .version) | |
if [ $version != $base_version ]; then | |
curl -s -X POST --data-urlencode "payload={\"username\": \"Chrome Extension Checker\", \"text\": \"Extension <https://chrome.google.com/webstore/detail/xxx/${extension_id}|${extension_id}> in Google Chrome Webstore has been upgraded to v${version}\", \"icon_emoji\": \":arrow_double_up:\"}" ${webhook_url} > /dev/null | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment