Skip to content

Instantly share code, notes, and snippets.

@wgkoro
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wgkoro/11201672 to your computer and use it in GitHub Desktop.
Save wgkoro/11201672 to your computer and use it in GitHub Desktop.
Flickr Credit bookmarklet
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