0

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.

relidon
  • 2,142
  • 4
  • 21
  • 37

1 Answers1

0

Read it from document.querySelector('a.ytp-title-link').textContent

wOxxOm
  • 65,848
  • 11
  • 132
  • 136