Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save PhilippGrulich/7051832b344d4cbd30fbfd68524baa38 to your computer and use it in GitHub Desktop.
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
javascript:(function() {
var relativeTimeElements = window.document.querySelectorAll("relative-time");
relativeTimeElements.forEach(function(timeElement){
timeElement.innerHTML = timeElement.innerHTML +" -- "+ timeElement.title;
})
}())
@manumns
Copy link

manumns commented Apr 15, 2025

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>;
});
}())

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment