3

I need help with changing Safari's user agent permanently by editing the plist file.

Usually one would go to Preferences > Advanced > Show Developer mode in menu bar. Then Develop > User Agent > Chrome - Windows for example. However, when you open a new tab or window, this goes back to Default (Safari). This is expected behaviour. In the past, it was possible to edit a line that determined the user agent in /Users/(user)/Library/Preferences/com.apple.Safari.plist.

There was a line called: CustomUserAgent. It's not there anymore. How can I create it (with defaults probably) with the user agent of Chrome (Mac)? Alternatively, is there another way to change it, or has the procedure changed? I called Apple Support to no avail.

This is an old trick as the CustomUserAgent string is not there anymore. Forum article for reference: "Permanently change Safari's User Agent string"

I tried also this, but when I use the default write command it seems not to have any effect.

1 Answer 1

1

Disclaimer: BE VERY CAREFUL DISABLING System Integrity Protection.

the plist file is now located in /System/Library/Preferences/. You can edit this by logging in as root (see Enable Root User), disabling System Integrity Protection from recovery with csrutil -disable and csrutil authenticated-root disable (go find a tutorial) unmounting the system snapshot, and mounting a folder to that disk (for example if your disk was called /dev/disk1s3, you would run

sudo mkdir mnt
sudo mount -o nobrowse -t apfs /dev/disk1s3 mnt/

go into /private/var/root/mnt (should show disk icon and appear as Macintosh HD or name of your boot volume)

You can change the defaults to your user agent with this command:

defaults write com.apple.Safari CustomUserAgent "\"useragentstring\""

On Intel Mac run:

sudo bless --folder mnt/System/Library/CoreServices --bootefi --create-snapshot && sudo dsenableroot -d && sudo reboot

or on Apple Silicon:

 sudo bless --mount "mnt/System/Library/CoreServices/" --setBoot --create-snapshot && sudo dsenableroot -d && sudo reboot

then you're done!

1
  • 2
    Why are you blessing a partition in which you only edit an unspecified Preference plist?
    – Allan
    Commented Mar 22, 2023 at 21:07

You must log in to answer this question.

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