Created
July 26, 2011 01:02
-
-
Save glyphobet/1105680 to your computer and use it in GitHub Desktop.
Firefox bookmarklet to get the current page's short URL, if one is defined. If no short URL is defined, gives you the option of getting one from TinyURL instead.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
var promptURL=function (url){ | |
window.prompt("Copy short URL to clipboard:",url); | |
}; | |
var links=document.getElementsByTagName('link'); | |
for(var i=0;i<links.length;i++){ | |
var tag=links[i]; | |
if(tag.getAttribute('rel')=='shorturl' || tag.getAttribute('rel')=='shortlink' || tag.getAttribute('id')=='shorturl' || tag.getAttribute('id')=='shortlink'){ | |
promptURL(tag.getAttribute('href')); | |
return; | |
} | |
} | |
if(document.getElementById('shortenurl')){/*Shapeways support*/ | |
promptURL(document.getElementById('shortenurl').children[0].value); | |
return; | |
} | |
if(window.confirm("No short URL for this page found. Create one at TinyURL?")){ | |
document.location='http://tinyurl.com/create.php?url='+encodeURIComponent(location.href); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment