Skip to content

Instantly share code, notes, and snippets.

@glx22
Last active August 9, 2022 21:24
Show Gist options
  • Save glx22/5d7c9ea72a6bfa2aeb820e3c1363eba7 to your computer and use it in GitHub Desktop.
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")
// ==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("&lt;" + username + "&gt;") && 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