I built a [widget][1] that grabs the URL from the frontmost window in Safari, then allows you to shorten it using the tr.im API. Works sweet as.
I want to make this more flexible, so am investigating how to grab an URL from other browsers. Here's the AppleScript that works in Safari:
tell application "Safari"
return URL of front document as string
end tell
After some digging, I determined that the following might work for Firefox (though one person has told me it doesn't work for him, possibly a conflict with some extension?):
tell application "Firefox"
set myFirefox to properties of front window as list
return item 3 of myFirefox
end tell
Note: The above is an example of a less-than-best practice, relying on the position of list items. See below for a better solution for Firefox.
What I'd like to do is build a list here of the definitive equivalents for every modern browser on the Mac: Opera, Camino, Flock, etc.
Update: In my research on the subject, I came across a helpful thread on MacOSXHints.com. Most of my answers below are based on that discussion.
Update 2: I've incorporated the AppleScript on this page into the [widget][1]. It seems to be working swell.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…