Surly and Furly

Applescripts to automatically create a TinyURL for or just grab the URL from the frontmost browser’s window.

In response to recent well-founded worries about URL-shortening services and inspired by John Gruber’s endorsement of Metamark, Dr. Drang posted a short script for getting the URL of the frontmost Safari window (or tab, as it were), shortening it with the Metamark URL-shortening service, and storing the result in the clipboard. Even better, it can all be done with a flick of the wrist in Quicksilver.

Awesome, but I don’t use Safari. So I created a pair of scripts to generate either a TinyURL or Metamark URL (‘Surly’, short for ‘Short URL’) and a script to simply grab the full URL from the frontmost tab or browser (likewise, ‘Furly’). Each sends the grabbed URL straight to your clipboard, and work automatically with your default browser. The scripts currently support Safari, Firefox, Camino, and Opera.

I will modify and create scripts for other URL-shortening services and browsers upon request by email. Also, don’t hesitate to send bug reports — you might get a Sakuzaku pin badge for your trouble.

Inspiration for these scripts is owed to the aforementioned Dr. Drang, to whom I extend many thanks. (If you’re writing about webpages, Dr. Drang’s furl script for getting full URLs is a great companion to Surly.) Thanks also to Daniel Bogan of Waferbaby, who provided testing and debugging.

Installation

Grab all the scripts in one easy-to-download package:

Or, you can browse the source directly.

Then, move the script you want to somewhere out of the way but where Quicksilver can find it. Dr. Drang recommends your home directory, but if you like to keep your directories clean, you can put it in ~/Library/Scripts, which Quicksilver will index automatically if you’ve enabled the “Scripts (User)” catalog item in the “Catalog” section of your Quicksilver preferences.

After a re-scan of the Quicksilver catalog (which you can force by activating QS and running ⌘+R, the appropriate scripts should be available.

Usage

Activate Quicksilver (or whatever you’re working with) and call up your script. If you want to create a TinyURL from your browser’s frontmost URL, for example, typing TinyURL should find TinyURL.scpt (if Quicksilver has figured out where you’ve stored it). Just hit Enter, and after a few seconds your shortened URL will be in the clipboard. Note that Metamark seems to take a few seconds more than TinyURL, but you shouldn’t need to wait more than 2 or 3 seconds for either of them.

To get the full URL, follow the same steps, typing Furl or Copy Frontmost Browser URL instead.

Paste away!