Minify URLs for Twitter

By n8 Last update May 27, 2009 — Installed 660 times.

Script Summary: Minify recognizes any URLs in what you are typing and automatically shortens them using the is.gd service.



2009 05 26 Update:

Fixed an encoding issue that prevented URIs with hashes from being encoded.

About:


This is a beta script that tries to solve a problem I'd been having while using Twitter's web interface. I would notice that Twitter was smart enough to shorten urls when I was under the 140 char limit (using tinyurl.com), but if I was over because of a url it wouldn't let me submit. This forced me to either tweet much smaller messages than I really was allowed or go to tinyurl or is.gd to shorten the url then paste it into the tweet by hand (which I'm too lazy to do).

Now as you type, if you press space any recognized urls are shortened automatically. Urls are also shortened before you submit to Twitter and if you paste in some text which puts the total tweet length over 140 char.

Disclaimer:


This is a beta script; I wrote it in a couple of hours and so you should use it at your own risk. I did use 'unsafeWindow' and 'windowJSObject' twice which may pose security risks. I ASSUME NO LIABILITY IF BAD THINGS HAPPEN TO YOU OR YOUR COMPUTER WHILE USING THIS SCRIPT. But I doubt that will happen.

Todo:


1) It would be nice if the script recognized "foo.com" as a url and shortened it so you have to type less.

2) It would be nice if when you put the cursor on a shortened url, it displayed the original url so that you could make any corrections or edits to the original url. The idea being that if you accidentally hit space or wanted to double check your urls you could before submitting.

3) It would be nice to abstract the shortening code a bit more and allow for
others to write plugins for tinyurl and other shortening services.