Skip to content

Instantly share code, notes, and snippets.

View lancewillett's full-sized avatar

Lance Willett lancewillett

View GitHub Profile
@lancewillett
lancewillett / shorten-bookmarklet.js
Created October 21, 2010 06:53 — forked from simonw/shorten-bookmarklet.js
Add support for shortlink
/* Expanded form of a bookmarklet for extracting rev=canonical OR tinyurling a page */
(function(){
var url=document.location;
var links=document.getElementsByTagName('link');
var found=0;
for(var i = 0, l; l = links[i]; i++) {
if (l.getAttribute('rev') == 'canonical' || (/alternate short/).exec(l.getAttribute('rel'))) {
found=l.getAttribute('href');
break;
}