By saipal
Has no other scripts.
// ==UserScript==
// @name Flickr Photo Link
// @version 0.6
// @namespace http://flickr.com/photos/saipal/201568378/
// @description Generate a small attributed Flickr photo link
// @include http://www.flickr.com/photos/*/*
// @include http://flickr.com/photos/*/*
// @exclude http://www.flickr.com/photos/*/*#preview
// @exclude http://flickr.com/photos/*/*#preview
// ==/UserScript==
/*
This is a Greasemonkey script. See http://greasemonkey.mozdev.org/ for more info.
If you're logged in to Flickr, this GM script generates a small attributed photo link
in the comment box on every Flickr photo page you visit. To post the photo in a
discussion thread or elsewhere, simply copy the generated HTML from the comment box
and paste it anywhere you like.
v 0.3 2006-07-29 Original release
v 0.4 2006-07-30 Upgraded compatibility with similar GM scripts
v 0.5 2006-07-31 Removed the <!-- comment --> tags
v 0.6 2006-08-02 Added photo title
*/
(function () {
textarea = document.evaluate("//textarea[@name='message']",
document, null, XPathResult.FIRST_ORDERED_NODE_TYPE,
null).singleNodeValue;
if(textarea) {
photosrc = document.evaluate("//img[@class='reflect']",
document, null, XPathResult.FIRST_ORDERED_NODE_TYPE,
null).singleNodeValue.src.replace(/\.[^\.]+$/, '_m.jpg');
phototitle = document.evaluate("//h1",
document, null, XPathResult.FIRST_ORDERED_NODE_TYPE,
null).singleNodeValue.innerHTML;
widget = document.evaluate("//div[@class='Widget']",
document, null, XPathResult.FIRST_ORDERED_NODE_TYPE,
null).singleNodeValue;
userstream = /href="(\S+)"/.exec(widget.innerHTML)[1];
usernick = /<b>(.+)<\/b>/.exec(widget.innerHTML)[1];
photoid = document.location.href.split('/')[5];
photolink = 'http://flickr.com' + userstream + photoid + '/';
userlink ='http://flickr.com' + userstream.replace(/\/photos\//,'/people/');
textarea.value = "\n" +
'<a title="' + phototitle + '" href="' + photolink +
'"><img src="' + photosrc + '" /></a>' +
"\n" + '<br />from <a href="' + userlink + '">' + usernick + '</a>' +
"\n" + textarea.value;
}
})();