I am trying to extract the youtube comments from a chrome extension. I am fairly new to extensions and I can't understand why this excerpt is not working the js file is:
chrome.tabs.onActivated.addListener((tab) => {
var tabId = tab.tabId;
chrome.tabs.get(tab.tabId, (current_info) => {
if (current_info.favIconUrl.includes("www.youtube.com")) {
chrome.tabs.executeScript(tabId, {
code: '('+function(){
return{
code: document.querySelectorAll('yt-formatted-string[class="style-scope
ytd-comment-renderer"][ slot="content"][id="content-text"]')
}
}+')()'
}, (res) => {
console.log(res);
})
}
});
});