How to get the new youtube title when yt-navigate-finish runs?

I have this code:

function run() {
  browser.runtime.sendMessage({
    action: "notify",
    payload: {
      url: window.location.href,
      title: document.title,
    },
  });
}
window.addEventListener("yt-navigate-finish", run, true);

The url is correct, when I click on a new youtube video, the url changes. But the title is from the old video.

For example, I got this result:

{ url: "https://www.youtube.com/watch?v=UwMlgKUQaQ4", 
title: "Spire Labs: Fault-tolerance with Kubernetes on AWS - YouTubetest" 
}

The URL is different, the title s different (the title is from the video I was on previously.

Hi @vendiim, it appears that this event does indeed fire right between updating the URL and updating the title; try listening to yt-update-title instead, this should do the trick.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.