Nowadays,
User:Ingenuity/timestamps.js is a topic that has captured the attention of many people around the world. With its relevance and impact on society,
User:Ingenuity/timestamps.js has become a point of interest for industries, governments and academics alike. From its inception to its current evolution,
User:Ingenuity/timestamps.js has been the subject of study, debate and innovation, leading to greater knowledge and understanding of its importance. In this article, we will explore the different facets of
User:Ingenuity/timestamps.js, analyzing its impact on various aspects of everyday life and its influence on future development.
function replaceAllTimestamps() {
if (location.href.includes("/Talk") || location.href.includes("/Wikipedia") ||
location.href.includes("/User_talk") || location.href.includes("/Wikipedia_talk") ||
location.href.includes("/Template") || location.href.includes("/Template_talk")) {
let list = Array.prototype.slice.call(document.querySelectorAll("span"));
for (let elem of list) {
try {
if (typeof elem.previousSibling.tagName === "undefined") {
continue;
}
let value = elem.previousSibling.previousSibling.nodeValue;
if (value === null) {
continue;
}
elem.previousSibling.previousSibling.remove();
let newElem = document.createElement("span");
newElem.innerHTML = value.replaceAll(/(\d\d\:\d\d,? \d\d? \w+ \d{4}) \(UTC\)/g, function(match, p1) {
let time = new Date(p1.replace(",", "") + " utc").getTime();
let diff = Math.floor((new Date().getTime() - time) / 60000);
let title = " minutes ago";
if (diff >= 60) {
diff = Math.floor(diff / 60);
title = " hours ago";
if (diff >= 48) {
diff = Math.floor(diff / 24);
title = " days ago";
if (diff >= 365 * 3) {
diff = Math.floor(diff / 365);
title = " years ago";
}
}
}
if (diff === 1) {
title = title.replace("s ", " ");
}
return `<span title="${match}">${diff + title}</span>`;
});
elem.parentNode.insertBefore(newElem, elem.previousSibling);
} catch (e) {}
}
}
console.log("Added timestamps");
}
if (document.readyState === "complete") {
replaceAllTimestamps();
} else {
window.addEventListener("load", replaceAllTimestamps);
}