Tag Archive for 'Safari'

Site search javascript booklet

You may have heard of a booklet or bookmarklet. These are simply snippets of javascript that are saved as bookmarks. They allow you to run a script within the context of the web page you are currently visiting. The following code allows you to perform a site specific search using Google’s search engine. Simply create a bookmark or favourite and replace the address contents with the following code:

javascript:Qr=prompt(‘Search%20site%20for’,”);if(Qr)location.href=’http://www.google.com/search?&q=site:’+encodeURIComponent(window.location.hostname)+’+’+escape(Qr)

Just copy and paste it all in one line, there are no line breaks or spaces anywhere in this script. Give the booklet an appropriate name, I call mine SiteSearch just because it makes sense to me. Now, when you are on any web page, select this booklet and you will be presented with a dialog box asking what to search for. Enter the text you are interested in, hit OK and Google will return the results for that site and that site only. This works with any javascript enabled browser including Internet Explorer, Firefox, Safari and Opera.

Enable the Safari Debug menu

Why would you want to? Well, one of the most useful facilities in the Debug menu is one that lets you change the User Agent. This enables you to tell the website you are using different browsers including Internet Explorer, Firefox, Netscape and Mobile Safari. This is useful for website development testing. In addition, as a result of lazy and inadequate development, some sites are blocking visitors who are not using Internet Explorer. By changing your User Agent you can bypass these stupid restrictions. Anyway, here’s what to do:

  1. Quit Safari
  2. Launch Terminal
  3. Type defaults write com.apple.Safari IncludeDebugMenu 1
  4. Re-start Safari and the debug menu will be enabled

To disable the debug menu, repeat the process but replace the 1 at the end of the terminal command with a zero.