I'm trying to set a variable equal to the favicon url of the current page. Are you not able to do this in the background script? How else could I get the current page's favicon url that the user is on?
background.js
var currentFaviconURL = document.querySelector("link[rel*='shortcut icon']").href;
console.log(currentFaviconURL);
console
Error in response to tabs.query: TypeError: Cannot read property 'href' of null
I'm trying to set a variable equal to the favicon url of the current page. Are you not able to do this in the background script? How else could I get the current page's favicon url that the user is on?
background.js
var currentFaviconURL = document.querySelector("link[rel*='shortcut icon']").href;
console.log(currentFaviconURL);
console
Error in response to tabs.query: TypeError: Cannot read property 'href' of null
Share
asked Aug 16, 2018 at 22:00
Marcus MartinMarcus Martin
1191 gold badge1 silver badge9 bronze badges
1 Answer
Reset to default 2For reading and manipulating DOM, you must use Content Scripts. https://developer.chrome./extensions/content_scripts