Category filter
Script to fetch Google Chrome extensions installed on Mac
Organizations consider Google Chrome a necessary utility that improves users’ browsing experience. However, as an administrator, if you want to exert more control over the Chrome browser and determine the extensions installed on the macOS devices, you can get it done quickly with the help of scripts. The Execute Custom Script action enables you to execute customized scripts for performing necessary operations tailored for your needs.
Get the list of extensions
Like every app, browser extensions also have a unique ID associated with them, where each extension ID is 32 characters long. The following scripts fetch the complete list of extension IDs installed on the devices.
1 2 3 4 5 6 7 |
#!/bin/bash currentUser=$(ls -l /dev/console | awk '{print $3}') ext_dir="/Users/$currentUser/Library/Application Support/Google/Chrome/Default/Extensions/" for i in $(find "$ext_dir" -name 'manifest.json'); do ue=$(basename "$(dirname "$(dirname "$i")")") echo "$ue" done |
The script iterates through each Chrome extension’s manifest.json file in every folder within the directory “/Users/$currentUser/Library/Application Support/Google/Chrome/Default/Extensions/”. It extracts the extension ID from the .json file and lists them, along with the user account, in the Action History of the Hexnode portal.
Find if a given extension is installed on Mac
The following scripts help you to determine if a specific extension is installed on Mac. You can search for a given extension on the device using its extension ID.
1 2 3 4 5 6 7 8 |
#!/bin/sh currentUser=`ls -l /dev/console | cut -d " " -f 4` if [ -d "/Users/$currentUser/Library/Application Support/Google/Chrome/Default/Extensions/extension_ID" ] ; then STATUS="The given extension is installed." else STATUS="Not installed." fi echo "<result>$STATUS</result>" |
For example,
1 2 3 4 5 6 7 8 |
#!/bin/sh currentUser=`ls -l /dev/console | cut -d " " -f 4` if [ -d "/Users/$currentUser/Library/Application Support/Google/Chrome/Default/Extensions/ nmmhkkegccagdldgiimedpiccmgmieda" ] ; then STATUS="The given extension is installed." else STATUS="Not installed." fi echo "<result>$STATUS</result>" |
The script checks whether the provided extension ID, “nmmhkkegccagdldgiimedpiccmgmieda”, is present within the Chrome extension directory. If the ID is found, it will display ‘The given extension is installed’. If it is not found, it will display ‘Not installed’.
To obtain the extension ID,
- Open Google Chrome on the device.
- Type in chrome://extensions on the search tab. It lists all the extensions installed on the device.
- Click on the Details button corresponding to the required extension. It appends the extension ID in the search bar.
- Navigate to /Users/currentUser/Library/Application Support/Google/Chrome/Default/Extensions on the macOS device by running the ‘open /Users/currentUser/Library/Application\ Support/Google/Chrome/Default/Extensions’ command in the Terminal app.
Ex: /Users/Darwin/Library/Application Support/Google/Chrome/Default/Extensions
- All the installed extensions can be found there, and the names of the folders found in this directory denote extension ID.