5

One of my friends has a child who is being overly sneaky online (imagine that). She wants to disable the ability for her child to select "Private Browsing" in Safari. In her opinion, Parental Controls are too limiting for a teenager, but Private Browsing is too permissive. Is there a terminal command or other way to do this on OS X?

(Of note: I did see the trick of using Interface Builder to edit the NIB file to delete the option from the Safari Menu, but I think it would be beyond her tech ability to perform those steps. I also doubt she'd want to install Xcode).

Thanks for you help!

  • Have you considered options such as K9 Web Protection? – bassplayer7 Dec 19 '13 at 0:33
  • She had used OpenDNS filtering/monitoring in the past as a similar strategy. I'm not sure why she wants to go the disabling route instead. – Ken B. Dec 19 '13 at 21:36
8

I could suggest something more evil :

Enable parental controls and use the logs !

Someone on Apple Support asked if private browsing disabled logging. It appears no, the parents controls will still log the websites. Even if the sneaky kids enable the private browsing, the logs will spill the beans !

  • 1
    Far more easy to log the websites on the router or via parental controls than it is to hack the app to change the behavior. +1 for solving the problem – bmike Dec 19 '13 at 2:48
2

If logging isn't practical or you want to be more proactive and prevent Private Browsing from being accessible in the first place, it is possible (though not a short process) to disable Private Browsing if you are willing to mess with Safari's internal files.

Note that macOS 10.12+ will not allow you to modify, overwrite, or delete Safari. You can make the following modifications to a copy of Safari and put that version in the Dock, but the original Safari will still need to exist in the Applications folder.

Install the necessary files

  1. Install Xcode (available in the App Store)
  2. Download a zip file of Nib-Decompiler from GitHub (or clone the repository if you know how to do that)
  3. Open the NibDecompiler.xcodeproj Xcode project in Xcode
  4. Compile the project. This will produce a file named NibDecompiler.action. You can now close the project.
  5. Copy NibDecompiler.action into ~/Library/Automator*
  6. From your download, copy NibDecompiler.workflow into ~/Library/Services*

Remove the "New Private Window" option from the menu bar

Note that this involves editing the Safari internal files. You will need to redo these steps every time you update Safari.

  1. Go to Safari in the Finder and right-click "Show Package Contents"
  2. This will open the app as if it were a folder. Go to Contents, then Resources, then Base.lproj folder.
  3. Find MainMenu.nib. Copy it outside of the package somewhere (like the Desktop).
  4. Right-click on the file and choose "NibDecompiler". The file will be made editable.
  5. Open the file in Xcode (should be double-clickable)
  6. In the window with the Safari menu, choose "Safari" to expand it.
  7. Click on the "New Private Window" menu item.
  8. Hit the delete key to see it disappear.
  9. Save the file.
  10. Back in the Base.lproj folder of the Safari app, make a copy MainMenu.nib just in case something goes wrong and you need to restore it.
  11. Copy your edited MainMenu.nib to Base.lproj, overwriting the existing one.
  12. Open Safari to make sure that it still opens (if it doesn't, restore your original MainMenu.nib file).
  13. (Optional) If everything works, you may delete the backup MainMenu.nib if you so choose.

By removing the "New Private Window" menu item from the menu bar, they will not be able to enter private browsing. Additionally, keyboard shortcuts are tied to menu items, so that's disabled too.


* ~ means your user home directory. Library is a hidden folder that isn't visible when you navigate to the home directory. You can get to this folder in the Finder by going to the "Go" menu and choosing "Connect to Folder…", then typing in ~/Library. You will then see the folders you need to copy files to.

Instructions copied from this MacRumors forum thread, updated for Safari 9 in this post.

  • This works perfectly, but once you've removed the menu option, you can still right click on the dock icon for safari and open a private window – simple_code Mar 6 '17 at 8:17
  • Or push cmd + shift + n for a new private window. – Joseph Hansen Mar 19 '17 at 17:44
  • @Joseph The key command is tied to the menu bar, and removing it removes the key command. – Thunderforge Mar 20 '17 at 14:30
-1

Click on Safari. Click on Preferences. Click on General. Go to first choice "Safari opens with" select "a new window". Mine was selected on the choice of "Safari opens with" "a new private window". This had been driving me crazy for a month.

  • Thanks for this very simple answer. All that stuff about Terminal and scripts and all I wanted was this straight forward solution! – user198815 Aug 26 '16 at 7:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .