Last active
August 29, 2015 14:00
-
-
Save wgkoro/11201672 to your computer and use it in GitHub Desktop.
Flickr Credit bookmarklet
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
javascript:(function(){ | |
var a,title, | |
divs = document.getElementsByTagName('div'), | |
len = divs.length; | |
for(var i=0;i<len;i++){ | |
if(divs[i].className == 'attribution-info'){ | |
a = divs[i].getElementsByTagName('a')[0]; | |
break; | |
} | |
} | |
var spans = document.getElementsByTagName('span'), | |
s_len = spans.length; | |
for(var i=0;i<s_len;i++){ | |
if(spans[i].className.match(/photo-title/)){ | |
title = spans[i].childNodes[0].nodeValue.replace(/ /g, '').replace(/\t/g, '').replace(/\n/g, ''); | |
break; | |
} | |
} | |
var url = document.location +''; | |
var author = a.childNodes[0].nodeValue; | |
var author_link = a.href; | |
var html = '<small>Photo: <a href="' +url +'" target="_blank">' +title +'</a> by <a href="' +author_link +'" target="_blank">' +author +'</a></small>'; | |
window.prompt('Credit', html); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment