Skip to main content
Jamf Nation, hosted by Jamf, is the largest Apple IT management community in the world. Dialog with your fellow IT professionals, gain insight about Apple device deployments, share best practices and bounce ideas off each other. Join the conversation.

Script to enable extension in Safari 10.X

I found some other forum posts about enabling Safari extensions programmatically but they were somewhat dated and the methods recommended haven't been working for me as of yet (it's possible I'm something wrong, though). So I'm asking if anyone has any recent experience with using a script or some other automated method to enable Safari extensions (not addins) for users? Or does anyone have recommendations of things to try? Any advice would be much appreciated.

Like Comment
Order by:
SOLVED Posted: 2/9/17 at 10:23 AM by chuinder

Pre-Sierra you can do some of this with AppleScript GUI automation, but this broke in Sierra due to SIP protection of the TCC.db file.
I had a case open with Apple for this and currently they are not providing options for this on purpose (security considerations), but they did put a feature request in for this.

If you're looking to do this pre-Sierra, I can share some of my scripts with you if you'd like.

SOLVED Posted: 2/9/17 at 10:39 AM by ndeal

Thanks! We definitely have a need on the Sierra platform but I would like to see the scripts you used for previous OS revs. We do still have El Cap and Yosemite machines in our environment.

I've opened a case with Apple on this. Maybe if enough people complain they will bump up the priority of the feature request. I appreciate the info!

SOLVED Posted: 2/9/17 at 10:50 AM by chuinder

Here you go, edited it some to remove some of the custom stuff we do here, but it should get you in the right direction:

tccPath="/Library/Application Support/"

sqlite3 "$tccPath" "INSERT or REPLACE INTO access VALUES('kTCCServiceAccessibility','',0,1,1,NULL,NULL)"          
sqlite3 "$tccPath" "INSERT or REPLACE INTO access VALUES('kTCCServiceAccessibility','/usr/bin/osascript',1,1,1,NULL,NULL)"
sqlite3 "$tccPath" "INSERT or REPLACE INTO access VALUES('kTCCServiceAccessibility','',0,1,1,NULL,NULL)"

# Give it some time to process..
sleep 1

# Now we're going to mess with UI elements. First we open the Extension, which initiates copy to ~/Library/Safari/Extensions/
# Then we're going to tell Safari to hit the Trust button, which creates the encryped keychain entry
# Then we close the Preferences Window by using Command + W.

osascript <<END
tell application "Safari" to activate
delay 1
tell application "System Events"
tell application process "Safari"
set frontmost to true
tell application "Safari" to open location "$packageExtLocation$extName"
delay 1
click button 1 of sheet 1 of window 1
keystroke "w" using command down
end tell
end tell
SOLVED Posted: 2/15/17 at 5:27 PM by ndeal

Thanks a bunch! Much appreciated.

I submitted a case to Apple and they instructed me to file a bug report/feature requests which was just closed with the rank of "no value" and a note that they have not plans to do this because of past issues with malware. Guess I won't get my hopes up for a change in the future.

SOLVED Posted: 2/15/17 at 6:10 PM by bentoms

Sorry about this... (someone at Apple reads my blog it seems)...

optional image ALT text

SOLVED Posted: 3/3/17 at 5:08 PM by ndeal

Why I oughta... ;)