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?
- First, download the extension.
- Next, find your Firefox profile folder.
- In your profile folder, find and open the “extensions/ShortenURL@loucypher/defaults/preferences” folder.
- You should then find a file named shortenURL_prefs.js – open it in any text editor.
- 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
- 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).
- 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!