Archive

Posts Tagged ‘Google Bot’

Custom User-Agent Safari

June 9th, 2010 Comments off

AppleSafari offers a pretty nice Developer toolbar (once enabled under Safari->Preferences->Advanced->Show develop menu…). As part of the developer toolbar they offer a User-Agent switcher to allow you to seemingly be using a different browser. Now, if you’re familiar with the User-Agent Switcher on Firefox, you know you can add additional/custom user agents. However, Safari doesn’t make it as easy to add additional/custom agents. Rest assured, there is still away.

The file you will be looking for is:

/Applications/Safari.app/Contents/Resources/UserAgent.plist

What I have done is copy this file off to my home directory. Open the file with the Property List Editor (provided with Apple’s developer tools). I will add 2 entries into this file. One to give a nice divider for my custom agents and another for the Google Bot Agent.

For the divider:

  1. Select the last ‘Item’ (be sure the ‘Item’ is not expanded) and click the ‘+’ sign to add a new ‘Item’
  2. Change this ‘Item’ to a ‘Dictionary’ under the ‘Type’ column.
  3. Expand this ‘Item’ and press the ‘Add sub-item button’ (replaced the ‘+’ sign after expanding)
  4. Rename this sub-item’s key to ‘separator’, change the type to Boolean, and select the Value checkbox.

User-Agent Separator Config

For the new User-Agent:

  1. Add a new ‘Item’ as you did in step 1 above.
  2. Change this ‘Item’ to a ‘Dictionary’ under the ‘Type’ column.
  3. Expand this ‘Item’ and press the ‘Add sub-item button’ (replaced the ‘+’ sign after expanding) 4 times.
  4. Set the key, type, value for each as follows:
  • name, String, Google Bot
  • version, String, 2.1
  • platform, String, Mac (not sure if this matters or not)
  • user-agent, String, Googlebot/2.1 (+http://www.google.com/bot.html)

User-Agent Custom Config

Save this file. Quit Safari. Replace the original with the new one.

$ sudo su -

# rm /Applications/Safari.app/Contents/Resources/UserAgents.plist

# cp /Users/derek/UserAgents.plist /Applications/Safari.app/Contents/Resources/

Fire Safari back up and there you have it. A new custom user-agent. Repeat as necessary to add more.

User-Agent Menu

Categories: Mac Tags: , ,