// ==UserScript== // @name Link to Pool contributions // @namespace http://web.chad.org/projects/flickr/gm // @description Link to a user's pool contributions from his profile // @include http://flickr.com/people/*/ // @include http://www.flickr.com/people/*/ // ==/UserScript== // Copyright Chad Miller, 2006 // license: GNU Public License // version: 0.1 // date Fri: Aug 25 01:03:26 UTC 2006 /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ function getElementsByClassName(classname, tagname) { return unsafeWindow.document.getElementsByClass(classname,tagname) } function urlToUser(queryHost, userUrl) { var apiUrl = "http://" + queryHost + "/services/rest/?method=flickr.urls.lookupUser&api_key=ee5741f2cce2160e4b955345b92f3587&url=" + userUrl; var useId; query = new XMLHttpRequest(); query.open("GET", apiUrl, false); query.send(null); if (query.responseXML) { userId = query.responseXML.getElementsByTagName("user")[0].getAttribute("id") ; } else { alert('Error retrieving userid'); } return userId; } function getUsername(txt) { var start = txt.split("")[1]; return start.split("")[0]; } var queryHost = location.href.split('/')[2]; var userPage = location.href; var userId = urlToUser(queryHost, userPage); var groupsSection = getElementsByClassName("Stats")[0]; var anchors = groupsSection.getElementsByTagName("a"); for (var i = anchors.length - 1; i >= 0; i--) { var anchorHref = anchors[i].getAttribute("href"); var groupLink = document.createElement("a"); groupLink.appendChild(document.createTextNode("u@")); groupLink.setAttribute("href", anchorHref + "pool/" + userId + "/"); var parent = anchors[i].parentNode; parent.appendChild(document.createTextNode(" - ")); parent.appendChild(groupLink); }