Permanently change User Agent string in Safari and Chrome

In Safari you can change the User Agent string by using the developers option “Develop -> User Agent -> Other”. However, this will change the user agent just temporally. After you restart Safari, the old User Agent string will be used. If you want to permanently change the User Agent string you need to run the following command:
defaults write CustomUserAgent "\" your new user agent string \""

To change the default User Agent in Chrome you should create an application with the Automator. Run Automator, select Application as type of document, in the Library search for “Run Shell Script” -> double click, change the cat command with the following command
open -a "Google Chrome" --args --user-agent="your new user agent string"
save it in your Applications folder. Thats it!
If you have a shortcut to your old Google Chrome in the Dock, remove it. Then, start your newly created Chrome application and pin it to the Dock (right click -> Options -> Keep in Dock).
To change the icon of the newly created application you can do the following: right click on the old Google Chrome application -> Get Info -> click on the Chrome icon in the top left corner -> Cmd-C. Then, Get Info on your new application -> click on the icon in the top left corner -> Cmd-V.
Now the user agent string will be the one you wanted!

This entry was posted in hacking, mac os. Bookmark the permalink.

5 Responses to Permanently change User Agent string in Safari and Chrome

  1. nikola says:

    Bravo batka bash toa sho mi trebaseh.


  2. Sebastian says:

    Would this be possible for certain sites only? I would like to use Safari 7.1 for YouTube, since Google doesn’t allow Flash in Safari 8 anymore.

  3. stefan says:

    ty. and what would be the proper syntax for the user agent string for internet explorer?

  4. stefan says:

    never mind, hovering over the develop menu shows this this for IE9:
    Mozilla/5.0 (compatible; MSIE; WindowsNT 6.1; Trident/5.0)

    screenshot enables capturing the info