- Fixed a bunch of bugs for existing paginations
[FlickrHacks.git] / _greasemonkey_ / flickrmoregrouplinks.user.js
blob3c9edba365528f21ec76551ae6ea7ff7a0bf60d6
1 // ==UserScript==
2 // @name        Flickr More Group Links
3 // @namespace   http://6v8.gamboni.org/
4 // @description Add more links to browse a group pool (random photos, leech, etc..)
5 // @version        0.3
6 // @identifier  http://6v8.gamboni.org/IMG/js/flickrmoregrouplinks.user.user.js
7 // @date           2006-08-25
8 // @creator        Pierre Andrews (mortimer.pa@free.fr)
9 // @include http://*flickr.com/groups/*
10 // @exclude http://*flickr.com/groups/
11 // @exclude http://*flickr.com/groups
12 // ==/UserScript==
14 // --------------------------------------------------------------------
16 // This is a Greasemonkey user script.
18 // To install, you need Greasemonkey: http://greasemonkey.mozdev.org/
19 // Then restart Firefox and revisit this script.
20 // Under Tools, there will be a new menu item to "Install User Script".
21 // Accept the default configuration and install.
23 // --------------------------------------------------------------------
24 // Copyright (C) 2006 Pierre Andrews
25 // 
26 // This program is free software; you can redistribute it and/or
27 // modify it under the terms of the GNU General Public License
28 // as published by the Free Software Foundation; either version 2
29 // of the License, or (at your option) any later version.
30 // 
31 // This program is distributed in the hope that it will be useful,
32 // but WITHOUT ANY WARRANTY; without even the implied warranty of
33 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
34 // GNU General Public License for more details.
35 // 
36 // The GNU General Public License is available by visiting
37 //   http://www.gnu.org/copyleft/gpl.html
38 // or by writing to
39 //   Free Software Foundation, Inc.
40 //   51 Franklin Street, Fifth Floor
41 //   Boston, MA  02110-1301
42 //   USA
45 (function () {
47         //update information
48         var SCRIPT = {
49                 name: "Flickr More Group Links",
50                 namespace: "http://6v8.gamboni.org/",
51                 description: "Add more links to browse a group pool (random photos, leech, etc..)",
52                 identifier: "http://6v8.gamboni.org/IMG/js/flickrmoregrouplinks.user.js",
53                 version: "0.3",                                                         // version
54                 date: (new Date("2006-08-25"))          // update date
55                 .valueOf()
56         };
57         
58         
59         function M8_log() {
60                 if(unsafeWindow.console)
61                         unsafeWindow.console.log(arguments);
62                 else
63                         GM_log(arguments);
64         }
66         var flickrmoregrouplinks = function() {this.init();}
68         flickrmoregrouplinks.prototype = {
70                 init: function() {
71                         var links = document.evaluate(
72                                                                                  "//td[@class='Section']/p[@class='Links']",
73                                                                                  document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null
74                                                   ).singleNodeValue;
76                         var a = links.getElementsByTagName('a');
77                         var id;
78                         var admin = false;
79                         for(var i=0;i<a.length;i++) {
80                                 if(a[i].href.indexOf('?id=') >= 0)
81                                         id = a[i].href.split('?id=')[1];
82                                 if(a[i].href.indexOf('/admin/') >=0)
83                                         admin = true;
84                         }
85                         if(id) {
86                                 links.innerHTML += '<img width="1" height="11" alt="" src="/images/subnavi_dots.gif"/>';
87                                 links.innerHTML += '<a href="http://www.krazydad.com/gustavog/FlickRandom.pl?group='+id+'">Random</a>';
88                                 links.innerHTML += '<img width="1" height="11" alt="" src="/images/subnavi_dots.gif"/>';
89                                 links.innerHTML += '<a href="http://www.flickrleech.net/group/'+id+'">Leech</a>';
90                                 links.innerHTML += '<img width="1" height="11" alt="" src="/images/subnavi_dots.gif"/>';
91                                 links.innerHTML += '<a href="http://www.flickr.com/groups/'+id+'/pool/'+unsafeWindow.global_nsid+'">Your Photos</a>';
92                                 if(admin) {
93                                         links.innerHTML += '<img width="1" height="11" alt="" src="/images/subnavi_dots.gif"/>';
94                                         links.innerHTML += '<a href="http://flagrantdisregard.com/flickr/poolcleaner.php?group_id='+id+'">Pool Cleaner</a>';
95                                 }
96                         }
97                 }
98         }
99         //======================================================================
100         // launch
101         try {
102                 window.addEventListener("load", function () {
103                                                                         try {
104                                                                                 
105                                                                                 // update automatically (http://userscripts.org/scripts/show/2296)
106                                                                                 win.UserScriptUpdates.requestAutomaticUpdates(SCRIPT);
107                                                                         } catch (ex) {} 
108                                                                         
109                                                                         var flickrgp = new flickrmoregrouplinks();
110                 }, false);
111         } catch (ex) {}
112 })();