Created
January 15, 2015 23:54
-
-
Save anonymous/454e78d1dbd47aeb81c4 to your computer and use it in GitHub Desktop.
Moodle Plugin Advanced Forum Timestamp Correction
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 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