One of the great new features of Snow Leopard is the ability thru Automator (and by extension, AppleScript) to make your own service. Automator can set-up services to accept specific inputs (ie files, images, or text) to act on. If you have selected the appropriate type of input, the service will show up in your context menu.
To create a service which generates a tr.im shortened URL when control-clicking a link in Safari. First, open Automator, and select Create a New Service. Set the Service to receive selected text in Safari.
Find Run AppleScript from the Action library on the left, and drag that over to the right half of the Automator window. In that area, paste in the following:
on run {inText}
tell application "Safari"
activate
set searchTerm to inText
set xNow to do JavaScript "
var x,
z,
i;
x = '" & searchTerm & "';
if (x != null) {
x = x.toLowerCase();
z = document.links;
for (i = 0; i < z.length; ++i) {
if ((z[i].innerHTML && z[i].innerHTML.toLowerCase().indexOf(x) != -1) || z[i].href.toLowerCase().indexOf(x) != -1) {
z[i].style.color = '#2e2e2e !important';
sndT = 'http://tr.im/marklet?url=' + escape(z[i].href);
popup_window = window.open(sndT);
}
}
}
" in document 1
end tell
end runMac OS X Hints
http://hints.macworld.com/article.php?story=20090827160243198