-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathWikipediaDeLocationCategories.js
More file actions
44 lines (43 loc) · 1.07 KB
/
Copy pathWikipediaDeLocationCategories.js
File metadata and controls
44 lines (43 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
javascript:
/* creates template for a category when being on entry of German Wikipedia article about the place */
var lat = "";
var lon = "";
var coor = "";
try
{
lat = document.getElementsByClassName("latitude")[0].innerHTML + "";
lon = document.getElementsByClassName("longitude")[0].innerHTML + "";
coor = "coordinate=" + lat + "," + lon;
if(coor.indexOf("°")>-1)
{
coor = "coordinate=" + document.getElementsByClassName("geo")[0].innerText.replace("; ", ",");
}
}
catch(err)
{
alert("careful: no coordinates found");
}
var wikidata = "|wikidataID=";
var allAnkerNodes = document.getElementsByTagName("a");
for (var i=0; i < allAnkerNodes.length ; i++)
{
if ( href = allAnkerNodes[i].getAttribute("href"))
{
hrefParts = href.split("/");
if(hrefParts[4]=="Special:EntityPage")
{
wikidata = wikidata + hrefParts[5];
break;
}
}
}
var output = "{{CategoryInfoBox Location\n|parent=\n|project=\n|team=\n|" + coor + "\n"+ wikidata + "\n}}";
if (navigator.userAgent.includes("Chrome"))
{
prompt("", output);
}
else
{
alert(output);
}
void(0);