-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathFindAGraveCat.js
More file actions
85 lines (74 loc) · 2.18 KB
/
Copy pathFindAGraveCat.js
File metadata and controls
85 lines (74 loc) · 2.18 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
javascript:
var IS_BOOKMARKLET = true;
var _id = document.getElementsByClassName('copyme')[0].innerText;
var _name = document.querySelector('[itemprop=name]').innerText;
var _lat = "";
var _lon = "";
try
{
_lat = document.querySelector('[title=Latitude\\:]').innerText;
_lon = document.querySelector('[title=Longitude\\:]').innerText;
}
catch
{}
var _location = document.querySelector('[itemprop=addressLocality]').innerText;
var _locationParts = _location.split(", ");
var _county = _locationParts[_locationParts.length-1];
var _state = document.querySelector('[itemprop=addressRegion]').innerText;
var _locationCategory = _county + ", " + _state;
if(!IS_BOOKMARKLET && _locationParts.length > 1)
{
const potentialCityCategory = _locationParts[0] + ", " + _state;
let catUrl = "https://www.wikitree.com/wiki/Category:" + encodeURI(potentialCityCategory);
let xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", catUrl, false); /* false for synchronous request */
xmlHttp.send(null);
if (xmlHttp.status < 400) {
_locationCategory = potentialCityCategory;
}
}
/*var _country = document.querySelector('[itemprop=addressCountry]').innerText;*/
var _catName = _name + ", " + _locationParts[0] + ", " + _state;
var _address = "";
try
{
_address = document.querySelectorAll('[itemprop=address]')[1].innerHTML.replace("<br>", ", ").trim();
}
catch
{
}
var _aka = "";
try
{
_aka = document.querySelector('[itemprop=alternateName]').innerText;
}
catch
{
}
var output = "{{CategoryInfoBox Cemetery " +
"\n|name=" + _name +
"\n|aka=" + _aka +
"\n|address=" + _address +
"\n|parent=" + _county + ", " + _state +
"\n|location=" + _locationCategory +
"\n|spacepage= "+
"\n|wikidataID="+
"\n|findagraveID=" + _id +
"\n|billiongravesID= "+
"\n|webpage= "+
"\n|searchwebpage= "+
"\n|coordinate="+ _lat + "," + _lon +
"\n|startdate= "+
"\n|enddate=\n}}";
if (navigator.userAgent.includes("Chrome"))
{
prompt("", output);
}
else
{
alert(output);
}
var otherWin = window.open("https://www.wikitree.com/index.php?title=Category:" + _catName + "&action=edit");
var billon = "https://www.google.com/search?q=" + encodeURIComponent("site:https://billiongraves.com " + _name + " " + _location);
var win = window.open(billon);
void(0);