User:Killr833/youtubeshortlink.js

/* Meant to be used as a bookmarklet */

function getParam(name) { name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); var regexS = "[\\?&]"+name+"=([^&#]*)"; var regex = new RegExp( regexS ); var results = regex.exec( window.location.href ); if( results == null ) return ""; else return results[1]; } var shortUrl = 'http://youtu.be/' + getParam(v);

var div_embed=document.getElementById('watch-embed-div');

if(div_embed) { var div_shortlink=document.createElement('div'); div_shortlink.innerHTML=' Short link: ' + shortUrl + ' '; div_embed.appendChild(div_shortlink)}}); void(0)