This is a bookmarklet that finds a canonical short url from the current webpage (or creates a new bit.ly url if none exists) and then sends that to Twitter as the basis of a new tweet.
The bookmarklet first tries to find any one of the following: rev='canonical'
, rel='shortlink'
, rel='shorturl'
, rel='alternate short'
, or rel='alternate shorter'
. If the page doesn't have one of the above, it then uses the bit.ly api to create a short url for you.
The idea for this came from Lachlan Hardy's Tweet-Canonical.
The bulk of the code came from Joel Watts's gist. I simply swapped the prompt for the Twitter redirect.
To install the bookmarklet, first you'll need to add your BITLY_USERNAME
and BITLY_API_KEY
. You can get the latter from your bit.ly Account
Then you'll need to paste the JS into a bookmarklet builder such as this.
Copyright (c) 2010 Phil Oye under the MIT License. See LICENSE for details.