Viewing posts tagged with flickr

Flickr and Youtube Bookmarklet

Here is a little bookmarklet I created to grab the short URL when viewing a video on YouTube or a photo on Flickr:

javascript: (function () {
    var a = location.host;
    if (a.indexOf('flickr') > 0) {
        var a = document.getElementsByTagName('html')[0].innerHTML;
        var b = a.match('http://flic.kr/p/([_a-zA-Z0-9]*)');
        if (b) prompt('The flic.kr URL is:', b[0]);
    }
    if (a.indexOf('youtube') > 0) {
        var a = document.getElementsByTagName('link');
        for (var i in a) {
            var b = a[i];
            if (b.getAttribute('rel') == 'shortlink') prompt('The youtu.be URL is:', b.getAttribute('href'));
        }
    }
})()

To use it, simply drag the link below onto your browser toolbar, and then click it when viewing a video or photo.

Grab Short URL