Skip to content

Instantly share code, notes, and snippets.

@verfasor
Created November 23, 2025 09:51
Show Gist options
  • Select an option

  • Save verfasor/e7c899536f74a575509f10b26ab19d91 to your computer and use it in GitHub Desktop.

Select an option

Save verfasor/e7c899536f74a575509f10b26ab19d91 to your computer and use it in GitHub Desktop.
script to show post time next to date on bear blog (minified)
<script>(function(){function addTimeToPostDates(){if(!document.body.classList.contains('post')){return}
const timeElements=document.querySelectorAll('main time');timeElements.forEach(timeEl=>{if(!timeEl.dateTime)return;const postDate=new Date(timeEl.dateTime);const now=new Date();const isToday=postDate.getDate()===now.getDate()&&postDate.getMonth()===now.getMonth()&&postDate.getFullYear()===now.getFullYear();let hours=postDate.getHours();const minutes=postDate.getMinutes();const ampm=hours>=12?'PM':'AM';hours=hours%12;hours=hours?hours:12;const minutesStr=minutes.toString().padStart(2,'0');const timeStr=`${hours}:${minutesStr} ${ampm}`;const currentDateText=timeEl.innerText.trim();if(isToday){timeEl.innerText=`Today • ${timeStr}`}else{timeEl.innerText=`${currentDateText} • ${timeStr}`}})}
if(document.readyState==='loading'){document.addEventListener('DOMContentLoaded',addTimeToPostDates)}else{setTimeout(addTimeToPostDates,100)}})()</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment