Posted on 09-20-2013 08:41 AM
I've done a fair amount of googling and came up with
To Disable the blocker
defaults write com.apple.safari WebKitJavaScriptCanOpenWindowsAutomatically 1
To Enable the blocker
defaults write com.apple.safari WebKitJavaScriptCanOpenWindowsAutomatically 0
But it doesn't seem to be effective on Safari version 6.0.5 and the website I found it on was for an older version of OS X. I'm usually pretty darn good at figuring things out but this has me pulling my hair out. Rarely do I seek out help but this time I'm REALLY hoping someone can throw me a rope here.
Any thoughts as to how I can do this so I can script it and push it out?
Thanks in advance.
Posted on 09-20-2013 09:39 AM
Are you the nick that replied to my site?
http://macmule.com/2012/07/31/disabling-safari-5-1-xs-6-xs-pop-up-blocker-from-terminal-2/
Sorry if so, I need to update that more!
Is this better?
Display Name: Safari 5.1+ Disable Pop-Up Blocker
Application Domain: com.apple.Safari
Key Name: com.apple.Safari.ContentPageGroupIdentifier.WebKit2JavaScriptCanOpenWindowsAutomatically
Key Type: boolean
Key Value: true
Posted on 09-20-2013 10:07 AM
Thanks for the reply! I can't check your site (though I've been there before) from our internal network but I'll have a look at it when I can throw a spare MacBook on our customer wlan.
I ran it like so in terminal:
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2JavaScriptCanOpenWindowsAutomatically -bool YES (per your site)
but above you put the key value to true so do I have to end that line with "TRUE" instead of "YES"?
Also is it supposed to show the "Block pop-up windows" unchecked? I'm running the command with Safari closed of course but when I open it and view Preferences it's still showing the box is checked. Just wondering. Again thanks for your response and help!!
Posted on 09-20-2013 10:58 AM
Sorry. Typo in blog.
Should be true as above & as I put in comments.
Amended the blog now!
Above is copied from my JSS.
Posted on 11-10-2016 12:22 PM
I don't mean to bring up old comments, but i'm trying to run this as a Login/Recurring checkin policy to push out to teacher MacBooks and I can't get it to work. The policy runs, the script runs, and the policy log states below....
STEP 1 of 4]
Executing Policy Disable Pop-Up Blocker in Safari for Teachers
[STEP 2 of 4]
Running script Disable Pop-Up Blocker in Safari...
Script exit code: 0
Script result:
[STEP 3 of 4]
[STEP 4 of 4]
what am I doing wrong? I've tried to use SUDO in the script line as well. The script works completely fine when I open terminal directly on the device. Is the script in JSS not writing to the user level like if you were to open terminal?
Posted on 11-10-2016 12:42 PM
@aaron.kelley Scripts in Jamf run as the root user, not the currently-logged-in user, so you're setting that preference for the root user. You may need to do some scripting wizardry to determine the logged-in user and run the commands as them...
Posted on 11-10-2016 12:55 PM
@RobertHammen I figured as much, but not sure how to do that, as i'm new to scripting.
Posted on 11-15-2016 10:31 AM
Any ideas? I'm still stumped on this.
Posted on 11-15-2016 10:50 AM
@aaron.kelley Give this a quick test...
#!/bin/bash
#Casper User variable
USER=$3
#Path to User's Safari plist
theFile=/Users/$USER/Library/Preferences/com.apple.Safari.plist
defaults write $theFile com.apple.Safari.ContentPageGroupIdentifier.WebKit2JavaScriptCanOpenWindowsAutomatically -bool true
Posted on 11-16-2016 08:47 AM
@millersc that didn't work :/
Posted on 11-16-2016 08:56 AM
Did it give any error? @aaron.kelley Also, I just noticed there is 2 spaces before "com.apple.Safari...." fix that and see again.
Posted on 11-16-2016 09:08 AM
@millersc It did not. It says it completed. I did noticed the 2 spaces and fixed it and tried with same results. Now when I try just the defaults write in terminal, it's saying "could not write domain /Users/aaron.kelley/Library/Preferences/com.apple.Safari; exiting"
Posted on 11-16-2016 09:17 AM
So for some reason my plist file is no longer in the ~/Library/Preferences folder...hmm.
EDIT: I copied it from my virtual testing machine. Plist is there again.
Posted on 09-06-2017 10:17 AM
FYI, found the solution here. https://www.jamf.com/jamf-nation/discussions/22170/script-to-disable-pop-up-blocker-in-safari