Last active
April 15, 2025 09:58
-
-
Save PhilippGrulich/7051832b344d4cbd30fbfd68524baa38 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"); | |
relativeTimeElements.forEach(function(timeElement){ | |
timeElement.innerHTML = timeElement.innerHTML +" -- "+ timeElement.title; | |
}) | |
}()) |
I've built up on @chemmi's code to show DD/MM/YYYY TMZ. Also, the text will show 80% smaller to fit the UI div in a nicer way:
javascript:(function() {
var relativeTimeElements = window.document.querySelectorAll("relative-time");
relativeTimeElements.forEach(function(timeElement) {
var date = new Date(timeElement.title);
var formattedDate = date.toLocaleString('en-GB', {
day: '2-digit',
month: '2-digit',
year: 'numeric',
hour: '2-digit',
minute: '2-digit',
hour12: false,
timeZoneName: 'short'
}).replace(',', '');
timeElement.shadowRoot.innerHTML = <span style="font-size: 80%;">${formattedDate}</span>
;
});
}())

Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using Chrome, I had to change the shadow root of the innerText to get the desired result.