I am making a chrome extension and I need to grab the title of youtube videos. I don't want to use the youtube api.
Solved it by doing var videotitle = document.title.split(" - YouTube")[0];
You can grab the tab title in the background.js, it will return the youtube video title
chrome.tabs.onActivated.addListener(function (activeInfo) {
chrome.tabs.get(activeInfo.tabId, function (tab) {
console.log("Title: " + tab.title);
});
});
You can also use this line of code in the F12 developer tools:
ytInitialPlayerResponse.videoDetails.title
The same line of code should work on your extension as well.