Last active
December 16, 2015 08:28
-
-
Save zoocoup/5405579 to your computer and use it in GitHub Desktop.
Add site to Safari's Java whitelist via script
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/sh | |
# Add a site to the Java whitelist in Safari with Safari 5.1.9+ on 10.6.x and Safari 6.0.4+ on 10.7+ | |
# Get the currently logged in user | |
LIU="`/usr/bin/w | grep console | awk '{ print $1 }'`" | |
# Make a copy of user's existing Safari prefs first before overwriting | |
cp /Users/$LIU/Library/Preferences/com.apple.Safari.plist /Users/$LIU/Library/Preferences/com.apple.Safari.plist_BAK | |
# Edit com.apple.Safari.plist to add new site to whitelist | |
/usr/libexec/PlistBuddy -c "Add :WhitelistedBlockedPlugins array" /Users/$LIU/Library/Preferences/com.apple.Safari.plist | |
/usr/libexec/PlistBuddy -c "Add :WhitelistedBlockedPlugins:0 dict" /Users/$LIU/Library/Preferences/com.apple.Safari.plist | |
/usr/libexec/PlistBuddy -c "Add :WhitelistedBlockedPlugins:0:PluginHostname string 'fermilab.kronoshosting.com'" /Users/$LIU/Library/Preferences/com.apple.Safari.plist | |
# Plistbuddy doesn't seem to like variables here (e.g. $HOSTNAME) so have to hardcode in value. | |
/usr/libexec/PlistBuddy -c "Add :WhitelistedBlockedPlugins:0:PluginIdentifier string 'com.oracle.java.JavaAppletPlugin'" /Users/$LIU/Library/Preferences/com.apple.Safari.plist | |
/usr/libexec/PlistBuddy -c "Add :WhitelistedBlockedPlugins:0:PluginLastVisitedDate string '2013-04-16T22:20:57Z'" /Users/$LIU/Library/Preferences/com.apple.Safari.plist | |
/usr/libexec/PlistBuddy -c "Add :WhitelistedBlockedPlugins:0:PluginName string 'Java Applet Plug-in'" /Users/$LIU/Library/Preferences/com.apple.Safari.plist | |
/usr/libexec/PlistBuddy -c "Add :WhitelistedBlockedPlugins:0:PluginPageURL string 'https://fermilab.kronoshosting.com/wfc09/applications/suitenav/navigation.do'" /Users/$LIU/Library/Preferences/com.apple.Safari.plist | |
# Plistbuddy doesn't seem to like variables here (e.g. $URL) so have to hardcode in value. | |
/usr/libexec/PlistBuddy -c "Add :WhitelistedBlockedPlugins:0:PluginPolicy string 'PluginPolicyNeverBlock'" /Users/$LIU/Library/Preferences/com.apple.Safari.plist | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment