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/11203069 to your computer and use it in GitHub Desktop.
Save wgkoro/11203069 to your computer and use it in GitHub Desktop.
Flickr credit for mobile
javascript:(function(){
var title,a,
divs = document.getElementsByTagName('div'),
len = divs.length;
for(var i=0;i<len;i++){
if(divs[i].className.match(/photo_meta/)){
title = divs[i].getElementsByTagName('h2')[0].childNodes[0].nodeValue.replace(/ /g, '').replace(/\t/g, '').replace(/\n/g, '');
break;
}
}
var ps = document.getElementsByTagName('p'),
p_len = ps.length;
for(var i=0;i<p_len;i++){
if(ps[i].className == 'photo-owner'){
a = ps[i].getElementsByTagName('a')[0];
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.location.href = 'slpro://' +html;
})();
// 一行化
// javascript:(function(){ var title,a, divs = document.getElementsByTagName('div'), len = divs.length; for(var i=0;i<len;i++){ if(divs[i].className.match(/photo_meta/)){ title = divs[i].getElementsByTagName('h2')[0].childNodes[0].nodeValue.replace(/ /g, '').replace(/\t/g, '').replace(/\n/g, ''); break; } } var ps = document.getElementsByTagName('p'), p_len = ps.length; for(var i=0;i<p_len;i++){ if(ps[i].className == 'photo-owner'){ a = ps[i].getElementsByTagName('a')[0]; 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.location.href = 'slpro://' +html; })();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment