-
Notifications
You must be signed in to change notification settings - Fork 47
/
Chrome_Extensions_(1).xml
75 lines (75 loc) · 3.18 KB
/
Chrome_Extensions_(1).xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?xml version="1.0" encoding="UTF-8"?>
<extensionAttribute>
<displayName>Chrome Extensions</displayName>
<description>Displays Name, Version and ID of installed Google Chrome Extensions for current or last user.
By default, data is displayed as:
Name: Extension Name
Version: Extension Version
ID: Extension ID.
However, if further data analysis is needed, an alternate output is available:
Name;Version;ID
The default output looks much prettier in the JSS, but the alternative output may be more useful.
To use the alternate output, simply comment out line:
echo -e "Name: $reportedName \nVersion: $version \nID: $extID \n"
And uncomment line:
echo -e "$reportedName;$version;$extID"</description>
<dataType>string</dataType>
<scriptContentsMac>#!/bin/bash
# Setting IFS Env to only use new lines as field seperator
IFS=$'\n'
currentUser=`ls -l /dev/console | awk {' print $3 '}`
lastUser=`defaults read /Library/Preferences/com.apple.loginwindow lastUserName`
if [[ "$currentUser" = "" || "$currentUser" = "root" ]]
then userHome=`/usr/bin/dscl . -read /Users/$lastUser NFSHomeDirectory | awk -F ": " '{print $2}'`
else userHome=`/usr/bin/dscl . -read /Users/$currentUser NFSHomeDirectory | awk -F ": " '{print $2}'`
fi
createChromeExtList ()
{
for manifest in $(find "$userHome/Library/Application Support/Google/Chrome/Default/Extensions" -name 'manifest.json')
do
name=$(cat $manifest | grep '"name":' | awk -F "\"" '{print $4}')
if [[ `echo $name | grep "__MSG"` ]]
then
msgName="\"`echo $name | awk -F '__MSG_|__' '{print $2}'`\":"
if [ -f $(dirname $manifest)/_locales/en/messages.json ]
then reportedName=$(cat $(dirname $manifest)/_locales/en/messages.json | grep -i -A 3 "$msgName" | grep "message" | head -1 | awk -F ": " '{print $2}' | tr -d "\"")
elif [ -f $(dirname $manifest)/_locales/en_US/messages.json ]
then reportedName=$(cat $(dirname $manifest)/_locales/en_US/messages.json | grep -i -A 3 "$msgName" | grep "message" | head -1 | awk -F ": " '{print $2}' | tr -d "\"")
fi
else
reportedName=$(cat $manifest | grep '"name":' | awk -F "\"" '{print $4}')
fi
version=$(cat $manifest | grep '"version":' | awk -F "\"" '{print $4}')
extID=$(basename $(dirname $(dirname $manifest)))
# This is the default output style - looks nice in JSS
# Comment out line below if you wish to use alternate output
echo -e "Name: $reportedName \nVersion: $version \nID: $extID \n"
# This is the alternate output style - looks ugly in JSS, but possibly more useful
# Uncomment line below to use this output instead
#echo -e "$reportedName;$version;$extID"
done
}
if [ -d "$userHome/Library/Application Support/Google/Chrome/Default/Extensions" ]
then result="`createChromeExtList`"
else result="NA"
fi
echo "<result>$result</result>"</scriptContentsMac>
<scriptContentsWindows/>
</extensionAttribute>