Skip to content

Instantly share code, notes, and snippets.

Created January 15, 2015 23:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/454e78d1dbd47aeb81c4 to your computer and use it in GitHub Desktop.
Save anonymous/454e78d1dbd47aeb81c4 to your computer and use it in GitHub Desktop.
Moodle Plugin Advanced Forum Timestamp Correction
// ==UserScript==
// @name Advanced-Forum-Timestamp-Correction
// @grant none
// @description Replaces time-ago with absolute date and time
// @include */mod/hsuforum/*
// ==/UserScript==
var snapFoo = document.evaluate("//*[@class='hsuforum-post-pubdate']",
document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
for (var i = snapFoo.snapshotLength - 1; i >= 0; i--) {
var newtimestamp = new Date(snapFoo.snapshotItem(i).attributes.datetime.value);
newtimestamp = newtimestamp.toLocaleString();
var prevtimestamp = snapFoo.snapshotItem(i).innerHTML;
prevtimestamp = prevtimestamp.concat(" - ");
prevtimestamp = prevtimestamp.concat(newtimestamp);
snapFoo.snapshotItem(i).innerHTML = prevtimestamp;
}
var snapFoo = document.evaluate("//*[@class='hsuforum-thread-pubdate']",
document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
for (var i = snapFoo.snapshotLength - 1; i >= 0; i--) {
var newtimestamp = new Date(snapFoo.snapshotItem(i).attributes.datetime.value);
newtimestamp = newtimestamp.toLocaleString();
var prevtimestamp = snapFoo.snapshotItem(i).innerHTML;
prevtimestamp = prevtimestamp.concat(" - ");
prevtimestamp = prevtimestamp.concat(newtimestamp);
snapFoo.snapshotItem(i).innerHTML = prevtimestamp;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment