Add a custom url shortener to Firefox

Posted by jon on Nov 30, 2009

I recently wrote a post about why I made my own url shortener. I’m now porting some of my common uses over to use this new shortener (keep life simple, right?). The first thing I wanted to address was adding an option to the right-click menu to shorten whatever page I was currently viewing and copy it to the clipboard. The easiest way I found to do this was to modify an existing Firefox addon called Shorten URL. It works particularly well because it already supports a TON of shortening services and adding new ones is a breeze. So how do you do it?

  1. First, download the extension.
  2. Next, find your Firefox profile folder.
  3. In your profile folder, find and open the “extensions/ShortenURL@loucypher/defaults/preferences” folder.
  4. You should then find a file named shortenURL_prefs.js – open it in any text editor.
  5. You should see two large blocks of similar lines repeating – find the last one in the first block (as of writing this it is pref("extensions.shortenURL.name.145", "w3t.org"); and add a new line below it (incrementing the number) and swap out the name w/ whatever you want to reference your url shortener as. (in my case pref("extensions.shortenURL.name.146", "jfox.in");
  6. Continue to the end of the file and you should find a matching url line pref("extensions.shortenURL.145", "http://w3t.org/?module=ShortURL&file=Add&mode=API&url=");. Add a new line below this one incrementing the number again (to match the one in the last step) and adding the url of the page to submit a url to shorten (the url will be appended to the end). For example: pref("extensions.shortenURL.146", "http://jfox.in/make-tiny.php?url="); (note the example here won’t actually work because my shortener is private).
  7. Save the file and restart Firefox. Now go to Tools->Add-ons, find ShortenURL in the list and select “preferences”. You should now be able to find your custom shortener in the list using the name you provided above (in my case jfox.in). Select your preference and enjoy!

A quick trailing note: This all assumes that your shortener has an interface that allows a url to be passed as a GET parameter and returns the shortened url in plain text as a result of that request. This is straight forward to implement, but worth mentioning. You should now be able to shorten simply by right-clicking and selecting the “Shorten this page URL” option (which will also copy the short url to your clipboard and put it in the location bar). Enjoy!


Posted in Code, General | 5 Comments »
Tags: , ,

My own short URLs

Posted by jon on Nov 1, 2009

A little while ago I setup my own short URL service on http://jfox.in. I already know there are tons of free services that already do this and there are even a few open source alternatives of projects aimed at this kind of thing…so why then did I decide to write my own? There are actually a couple reasons:

Anyone that is code savvy and is considering doing this – whatever your reasons – I definitely recommend doing it. It was simple and something I enjoyed, and it gives me the control I want in such a simple application. Not every problem makes sense to roll your own solution for, but this is one that does in my mind since it’s so simple.

I honestly wouldn’t be surprised if we see more web services offering their own custom URLs. It allows a bit more brand recognition and all the control issues I mention above. It also seems that short URL services aren’t going away anytime soon.

Do you have any thoughts on the merits of short URL services? Have you written your own or considered doing so?


Posted in Code, General | 5 Comments »
Tags: , ,