Tuesday, May 15, 2007

Greasemonkey extension - TinyURL for Gmail

This is a neat little hack for Gmail: if you find yourself pasting in links in the message window that are unruly, you can highlight the URL, hit ctrl-shift-T and Greasemonkey will auto-convert your URL into a TinyURL. Neat. (If you have Greasemonkey installed, click here to install the script.)



I ran into a problem though: ctrl-shift-T is the Firefox key-combo to re-open the last closed tab… which results in all kinds of excitement when you invoke this script. If you right-click on the Greasemonkey icon in your Firefox toolbar, select ‘manage user scripts’, find the Gmail TinyURL in the list of scripts, and click ‘edit’. In the text editor, look for this snippet of text:


if (event.ctrlKey  true &&
event.shiftKey true &&
event.keyCode 84) {


That “event.keyCode84” is a reference to the number associated with the letter T. I found a list of numeric codes that go along with event.keyCode here with that, I was able to change the active key from ‘T’ to ‘U’ (number 85), thereby avoiding the tab-reopening craziness. Save the text file, and now you hit ctrl-shift-U to perform the Gmail + TinyURL magic.

2 comments:

  1. I need to hack something up like this for http://turo.us

    We have a bookmarklet, but haven't got anything this fancy. Need to expand a bit on the (limited) API. :)

    ReplyDelete
  2. Mike - If you look at the underlying code in the script, I'm pretty sure you could just change the target URL from tinyurl.com to turo.us... From the bookmarklet that's on the site, it looks like there's a dedicated URL for creating a new URL on the fly... let me know if that works.

    ReplyDelete