I do a lot on the web. This may confuse some of you, but this is the reason that I use Safari as my primary browser. Safari is the only published browser that scores 100 on the Acid 3 test (I know, because I just checked). Safari also has a web inspector console which is (in my opinion) mostly superior to Firefox's web developer extensions. Web Developer has a few neat tricks, but I prefer Inspector.

Even still, there are numerous times when I'll need to view a page in another browser for testing, or because I'm curious. Since I have se7en browsers installed (not including emulated, simulated, virtual or command line ones) it has become tedious for me to click three levels into Safari's develop menu, and then switch back to Safari. So I created an AppleScript that will open my current page in all (read some) browsers.

Firstly, thanks to Jacob Rus for his menu_click function.

Secondly, here's the code.

``` – Open Page in All Browsers © 2009 Brian Bennett <bahamat @digitalelf.net>

– menu_click function found at http://www.macosxhints.com/article.php?story=20060921045743404 – Must have UI Scripting enabled.

set all_browsers to {} set end of all_browsers to "Firefox" set end of all_browsers to "Google Chrome" set end of all_browsers to "Opera" set end of all_browsers to "Camino (2.0b2)" set end of all_browsers to "OmniWeb" set end of all_browsers to "Webkit"

– Accepts a list of form: {"Finder", "View", "Arrange By", "Date"} – Execute the specified menu item. In this case, assuming the Finder – is the active application, arranging the frontmost folder by date.

on menu_click(mList) local appName, topMenu, r

– Validate our input if mList's length < 3 then error "Menu list is not long enough"

– Set these variables for clarity and brevity later on set {appName, topMenu} to (items 1 through 2 of mList) set r to (items 3 through (mList's length) of mList)

– This overly-long line calls the menu_recurse function with – two arguments: r, and a reference to the top-level menu tell application "System Events" to my menu_click_recurse(r, ((process appName)'s ¬ (menu bar 1)'s (menu bar item topMenu)'s (menu topMenu))) end menu_click

on menu_click_recurse(mList, parentObject) local f, r

f = first item, r = rest of items set f to item 1 of mList if mList's length > 1 then set r to (items 2 through (mList's length) of mList)

– either actually click the menu item, or recurse again tell application "System Events" if mList's length is 1 then click parentObject's menu item f else my menu_click_recurse(r, (parentObject's (menu item f)'s (menu f))) end if end tell end menu_click_recurse

– This is basically where it happens repeat with a from 1 to length of all_browsers set browser to item a of all_browsers as string

tell application "Safari" to activate menu_click({"Safari", "Develop", "Open Page With", browser}) delay 1 end repeat ```

You're welcome.