Forked from PhilippGrulich/Display commit timestamp at github as javascript bookmark
Last active
May 30, 2017 15:23
-
-
Save ltrebing/6b17b0648a4b36eb38b4f07f893bc991 to your computer and use it in GitHub Desktop.
This simple js bookmark let you display the correct commit timestamp at github
This file contains hidden or 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
javascript:(function() { | |
var relativeTimeElements = window.document.querySelectorAll("relative-time, time-ago, time.js-timeago"); | |
function pad(n) { | |
return n < 10 ? '0' + n : n; | |
} | |
relativeTimeElements.forEach(function(timeElement) { | |
var d = new Date(timeElement.attributes.datetime.value); | |
timeElement.innerHTML = | |
d.getFullYear() + '-' + | |
pad(d.getMonth()) + '-' + | |
pad(d.getDay()) + ' ' + | |
pad(d.getHours()) + ':' + | |
pad(d.getMinutes()) + ':' + | |
pad(d.getSeconds()); | |
}) | |
}()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment