Show week day and week number

I wrote some Javascript code to show week day and week number beside all journal page titles, like below:

I was going to make it a plugin, but writing it as a plugin I did not find a way to have access to the HTML elements I needed to modify. Instead I added a javascript file at my-graph/logseq/custom.js with the following:

function insertInfo() {
  console.log('inserting info');
  var journalTitles = document.querySelectorAll("span.title") // in page view this will find the page title
  if (journalTitles.length == 0)
    journalTitles = document.querySelectorAll("h1.title") // in journals view, this will find all visible journal titles
  for (let t of journalTitles) {
    addToElement(t)
  }
}
function addToElement(t) {
  const dateRegexMatch = new RegExp('([A-Z]\\w+) (\\d+)\\w\\w, (\\d\\d\\d\\d)$').exec(t.textContent)
  
  if (!!dateRegexMatch && dateRegexMatch.length == 4) {
      const journalDate = new Date(dateRegexMatch[1] + " " + dateRegexMatch[2] + " " + dateRegexMatch[3])
      
      const startDate = new Date(journalDate.getFullYear(), 0, 1);
      const days = Math.floor((journalDate - startDate) / (24 * 60 * 60 * 1000));
      const weekNumber = Math.ceil(days / 7);
      
      const dayOfWeekName = journalDate.toLocaleString(
        'default', {weekday: 'long'}
      );

      const span = document.createElement("span")
      span.style = "opacity:0.5;font-size:0.7em"
      span.innerHTML = " " + dayOfWeekName + ', Week ' + weekNumber
      t.append(span)
  }
}
var t=setInterval(insertInfo,1000);

And that did it for me. Feel free to use the code if you wish.

This is amazing! I wonder if you can help making something similar for yyyy-MM-dd type of date? I tried figuring out from your posted code but this is above my skill level for now.

This is what I have been wishing for! Unfortunately, same as the commentor above, I tried it in my graph but does not seem to work with date format do MMM yyyy.