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.
Here is the code in my content script
CodePudding user response:
Solved it by doing var videotitle = document.title.split(" - YouTube")[0];
CodePudding user response:
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);
});
});