Last active
August 29, 2015 14:00
-
-
Save wgkoro/11203069 to your computer and use it in GitHub Desktop.
Flickr credit for mobile
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 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