Last active
August 9, 2022 21:24
-
-
Save glx22/5d7c9ea72a6bfa2aeb820e3c1363eba7 to your computer and use it in GitHub Desktop.
greasemonkey script for local time for openttd weblogs (also show highlights for "glx")
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Local time for openttd weblogs | |
// @version 1 | |
// @include https://weblogs.openttd.org/* | |
// @include http://weblogs.openttd.org/* | |
// ==/UserScript== | |
var username = "glx" | |
var date = document.getElementsByClassName('info')[0].innerHTML.trim().split(' '); | |
date = date[date.length - 1]; | |
var allTimeAnchors = document.getElementsByClassName('anchor'); | |
for (var i = 0; i < allTimeAnchors.length; i++) { | |
var thisTimeAnchor = allTimeAnchors[i]; | |
var UTCdatetime = new Date(date + 'T' + thisTimeAnchor.innerHTML + 'Z'); | |
thisTimeAnchor.innerHTML = UTCdatetime.toLocaleTimeString(); | |
} | |
var allTexts = document.getElementsByClassName('text'); | |
for (var i = 0; i < allTexts.length; i++) { | |
var thisText = allTexts[i]; | |
if (!thisText.innerHTML.startsWith("<" + username + ">") && thisText.innerHTML.match(username)) { | |
thisText.style.backgroundColor = "yellow"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment