User:1ctinus/timeless.js
if ($("#ca-history").length > 0 && $("#footer-info-lastmod").length > 0){
$("#ca-history").children(1).text(Math.floor((new Date() - new Date($("#footer-info-lastmod").html().split("on ")[1].split(", at")[0])) / 86400000) + " Days ago");
}
$("img[src=\"//upload.wikimedia.org/wikipedia/en/thumb/1/1d/Information_icon4.svg/40px-Information_icon4.svg.png\"]").attr("src", "https://upload.wikimedia.org/wikipedia/commons/thumb/b/b6/Info_blauw.svg/40px-Info_blauw.svg.png");
document.body.addEventListener("keyup", (e) => {
if (e.key === "ScrollLock") {
let born = "";
let died = "";
let ret = "(–)";
try {
born = Array.from(document.querySelectorAll('tr'))
.find(el => el.innerText.includes("Born")).innerHTML.match(/[0-9][0-9][0-9][0-9]/)[0]} finally {}
try {
died = Array.from(document.querySelectorAll('tr'))
.find(el => el.innerText.includes("Died")).innerHTML.match(/[0-9][0-9][0-9][0-9]/)[0]} finally {}
if(born !== "" && died !== ""){
ret = "(" + born + "–" + died + ")";
} else if(born !== ""){
ret = "(born "+ born +")";
} else if(died !== ""){
ret = "(died " + died + ")";
}
document.getElementById("sdh-descriptionbox").firstChild.value += ret;
}
});