------------------------------------------------------------------------------------------------
# Author: Christopher Stone
# Created: 2012-05-03 : 10:42
# Modified: 2012-05-04 : 05:30
# Application: Safari
# Purpose: Report installed and enabled extensions.
# Dependencies: none
------------------------------------------------------------------------------------------------
on fDate() # Example: 2010.11.12 » 04.06.58
set formattedDate to do shell script "date \"+%Y.%m.%d » %H.%M.%S\""
return formattedDate
end fDate
------------------------------------------------------------------------------------------------
on joinList(listToJoin, deLimiter)
set {oldTIDS, AppleScript's text item delimiters} to {AppleScript's text item delimiters, deLimiter}
set joinedList to listToJoin as string
set AppleScript's text item delimiters to oldTIDS
return joinedList
end joinList
------------------------------------------------------------------------------------------------
try
set reportPath to "~/Desktop/\"Safari Extension Report " & fDate() & ".txt\""
set safariExtensionsPlist to "~/Library/Safari/Extensions/Extensions.plist"
set sep to "------------------------------------------------"
tell application "System Events"
tell property list file safariExtensionsPlist
tell property list item "Installed Extensions"
tell (property list items where name of its property list items contains "Enabled")
set enabledSafariExtansions to get value of property list item "Archive File Name"
end tell
end tell
tell property list items of property list item "Installed Extensions"
set installedSafariExtansions to get value of property list item "Archive File Name"
end tell
end tell
end tell
set enabledSafariExtansions to joinList(enabledSafariExtansions, linefeed)
set enabledSafariExtansions to do shell script "sort <<< " & quoted form of enabledSafariExtansions without altering line endings
set installedSafariExtansions to joinList(installedSafariExtansions, linefeed)
set installedSafariExtansions to do shell script "sort <<< " & quoted form of installedSafariExtansions without altering line endings
set reportText to {¬
sep, ¬
"SAFARI EXTENSIONS REPORT" & " » " & fDate(), ¬
sep, ¬
"ENABLED EXTENSIONS:", ¬
sep, ¬
enabledSafariExtansions, ¬
sep, ¬
"INSTALLED EXTENSIONS:", ¬
sep, ¬
installedSafariExtansions, ¬
sep, ¬
""}
set reportText to joinList(reportText, linefeed)
do shell script "cat <<< " & (quoted form of reportText) & " > " & reportPath
# Uncomment to open the report in TextEdit.
# do shell script "open -a TextEdit " & reportPath
on error eMsg number eNum
set {c, s} to {return, "------------------------------------------"}
set e to s & c & "Error: " & eMsg & c & s & c & "Error Number: " & eNum & c & s
beep
display dialog e
end try
------------------------------------------------------------------------------------------------