NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name FlickrBlogThis // @include http://www.flickr.com/photos/* // @include https://www.flickr.com/photos/* // @namespace https://www.flickr.com/photos/* // @description Generates HTML code for a blog posting from a flickr photo page // @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js // @grant GM_getResourceText // @grant GM_addStyle // @grant GM_xmlhttpRequest // @grant GM_getResourceURL // @grant GM_getResourceURL // @grant GM_registerMenuCommand // ==/UserScript== function scrollToElement(selector, time, verticalOffset) { // http://www.dconnell.co.uk/blog/index.php/2012/03/12/scroll-to-any-element-using-jquery/ time = typeof(time) != 'undefined' ? time : 1000; verticalOffset = typeof(verticalOffset) != 'undefined' ? verticalOffset : 0; element = $(selector); offset = element.offset(); offsetTop = offset.top + verticalOffset; $('html, body').animate({ scrollTop: offsetTop }, time); } function FlickrHTMLCode() { title = $('span.editable:nth-child(1)').text(); name = $("a.owner-name").first().text().replace(/^\s+|\s+$/g, ''); // arr = $("span.photo-name-line-1").find("a").attr("href").split("/"); theURL = document.URL; profile_name = theURL.split("/")[4]; u = theURL.match(/^(.*)\/in(.*)/); if (u) { newURL = u[1] + "/sizes/s/"; } else { newURL = document.URL + "sizes/s/"; } $.get(newURL, function(data) { img_src = $(data).find("div#allsizes-photo img").attr("src"); e = $(".title-desc-block"); if (e) { newElement = document.createElement("div"); newElement.innerHTML = '<textarea id=\"html_code\" cols=\"60\" rows=\"13\" wrap=\"virtual\">' + '<table style=\"margin-left: 10px; width: 20%;\" align=\"right\"><tbody><tr><td><a href=\"' + theURL + '\"><img alt=\"' + title + '\" src=\"' + img_src + '" /></a></td></tr><tr><td><small>\"<a href=\"' + theURL + '\">' + title + '</a>\" by <a href=\"'+ 'http://www.flickr.com/photos/' + profile_name + '/\" ' + '>' + name + '</a><i>.</i></small></td></tr></tbody></table> ' + '</textarea>'; $(e).parent().append(newElement); } // scrollToElement(e); alert($("#html_code").text()); $("#html_code").remove(); }); } GM_registerMenuCommand("Blog this flickr photo page", FlickrHTMLCode);