3 // @namespace http://6v8.gamboni.org/
4 // @description Links to the surf page from a photo
6 // @identifier http://6v8.gamboni.org/IMG/js/flickrsurf.user.js
8 // @creator Pierre Andrews (mortimer.pa@free.fr)
9 // @include http://*flickr.com/photos/*
12 // --------------------------------------------------------------------
14 // This is a Greasemonkey user script.
16 // To install, you need Greasemonkey: http://greasemonkey.mozdev.org/
17 // Then restart Firefox and revisit this script.
18 // Under Tools, there will be a new menu item to "Install User Script".
19 // Accept the default configuration and install.
21 // --------------------------------------------------------------------
22 // Copyright (C) 2006 Pierre Andrews
24 // This program is free software; you can redistribute it and/or
25 // modify it under the terms of the GNU General Public License
26 // as published by the Free Software Foundation; either version 2
27 // of the License, or (at your option) any later version.
29 // This program is distributed in the hope that it will be useful,
30 // but WITHOUT ANY WARRANTY; without even the implied warranty of
31 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 // GNU General Public License for more details.
34 // The GNU General Public License is available by visiting
35 // http://www.gnu.org/copyleft/gpl.html
37 // Free Software Foundation, Inc.
38 // 51 Franklin Street, Fifth Floor
39 // Boston, MA 02110-1301
45 var doclocation = new String(document.location);
46 if(doclocation.match(/\/surf\/?$/)) {
47 var previous = document.evaluate("/html/body/div[@id='Main']/table/tbody/tr/td[2]/a",
48 document.body, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null
50 var next = document.evaluate("/html/body/div[@id='Main']/table/tbody/tr/td[4]/a",
51 document.body, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null
54 var skipBack = document.evaluate("/html/body/div[@id='Main']/table/tbody/tr/td[1]/a[2]",
55 document.body, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null
58 var skipLogo = skipBack.previousSibling;
59 var back = skipBack.parentNode.insertBefore(document.createElement('a'),skipLogo);
60 back.parentNode.insertBefore(document.createTextNode(String.fromCharCode('8249')+' '),back);
61 skipBack.parentNode.insertBefore(document.createElement('br'),skipLogo);
62 back.href = previous.href+"/surf";
63 back.innerHTML = "Previous";
68 var skipFor = document.evaluate("/html/body/div[@id='Main']/table/tbody/tr/td[5]/a[2]",
69 document.body, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null
72 var forw = skipFor.parentNode.insertBefore(document.createElement('a'),skipFor);
73 skipFor.parentNode.insertBefore(document.createTextNode(' '+String.fromCharCode('8250')),skipFor);
74 skipFor.parentNode.insertBefore(document.createElement('br'),skipFor);
75 forw.href = next.href+"/surf";
76 forw.innerHTML = "Next";
80 var slideshow = document.evaluate("/html/body/div[@id='Main']/table[@id='Photo']/tbody/tr/td[2]/div[2]/table/tbody/tr/td[3]/div/div/div[contains(@id,'slideshowLink_stream')]",
81 document.body, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null
84 var div = slideshow.appendChild(document.createElement('div'));
85 div.className = 'showLink';
86 div.style.display = 'block';
87 var rootLocation = new String(document.location);
88 rootLocation = rootLocation.replace(/(http:\/\/(www.)?flickr.com\/photos\/[^\/]+\/[0-9]+)\/?.*$/i,"$1");
89 div.innerHTML = '<a href="'+rootLocation+'/surf/" title="surf from that photo">Surf</a>';