2 // @name Flickr Geo Info To Tag
3 // @namespace http://6v8.gamboni.org/
4 // @description Provide a button to transform geographic information provided by flickr map to usual tags.
6 // @identifier http://6v8.gamboni.org/IMG/js/flickrgeoinfototag.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
47 name
: "Flickr Geo Info To Tag",
48 namespace: "http://6v8.gamboni.org/",
49 description
: "Provide a button to transform geographic information provided by flickr map to usual tags.",
50 identifier
: "http://6v8.gamboni.org/IMG/js/flickrgeoinfototag.user.js",
51 version
: "0.1", // version
52 date
: (new Date("2006-08-28")) // update date
58 if(unsafeWindow
.console
)
59 unsafeWindow
.console
.log(arguments
);
64 function getObjectMethodClosure11(object
, method
,arg1
) {
65 return function(arg
) {
66 return object
[method
](arg
,arg1
);
70 var flickrgeoinfototag = function() {this.init();}
72 flickrgeoinfototag
.prototype = {
75 var moreLot
= document
.evaluate(
76 "//td[@class='RHS']/ul//li/a[@class='Plain']",
77 document
, null, XPathResult
.UNORDERED_NODE_SNAPSHOT_TYPE
, null
79 for(var i
= 0; i
< moreLot
.snapshotLength
; i
++) {
80 var map
= moreLot
.snapshotItem(i
);
81 if(map
.innerHTML
== 'map') {
82 var ul
= map
.parentNode
.appendChild(document
.createElement('ul'));
83 var coord
= map
.getAttribute('onclick');
85 if(matches
= /new YGeoPoint\(([0-9.-]+),([0-9.-]+)\)/.exec(coord
)) {
88 var li1
= ul
.appendChild(document
.createElement('li'));
89 li1
.className
= 'Stats';
90 var a1
= li1
.appendChild(document
.createElement('a'));
91 a1
.href
="javascript:;";
92 a1
.className
= 'Plain';
93 a1
.appendChild(document
.createTextNode('Add Geotags'));
94 a1
.addEventListener('click',getObjectMethodClosure11(this,'addtag',"geotagged geo:lon="+lon
+" geo:lat="+lat
),false);
96 var html
= map
.parentNode
.getElementsByTagName('b').item(0);
97 if(html
&& html
.innerHTML
) {
98 var tags
= html
.textContent
.split(',');
100 for each(t
in tags
) {
101 tut
+= '"'+t
.replace(/(^\s+|\s+$)/,'')+'" ';
103 var li2
= ul
.appendChild(document
.createElement('li'));
104 li2
.className
= 'Stats';
105 var a2
= li2
.appendChild(document
.createElement('a'));
106 a2
.href
="javascript:;";
107 a2
.className
= 'Plain';
108 a2
.appendChild(document
.createTextNode('Add Place Tags'));
109 a2
.addEventListener('click',getObjectMethodClosure11(this,'addtag',tut
),false);
117 addtag: function(evt
,tags
) {
118 unsafeWindow
.tagrs_addTag(unsafeWindow
.page_photo_id
,tags
);
121 //======================================================================
124 window
.addEventListener("load", function () {
127 // update automatically (http://userscripts.org/scripts/show/2296)
128 win
.UserScriptUpdates
.requestAutomaticUpdates(SCRIPT
);
131 var flickrgp
= new flickrgeoinfototag();