"Not allowed to load local resource: chrome: // favicon /"
I'm trying to load a url using chrome favicon url characters:
<img class='icon' src='chrome://favicon/yahoo.com' />
But im getting error:
"Not allowed to load local resource: chrome://favicon/yahoo.com"
And in the manifest I have:
"permissions": [
"chrome://favicon/"
],
This thread has a lot available online. Any suggestions?
+3
source to share
3 answers
Code problems
-
"permissions": ["chrome://favicon/"]
, is an invalid pattern in the manifest file
If you want to use the tab url favicon
, use the chrome.tabs API in the extension pages.
Demonstration
manifest.json
Registered background page and added required permissions.
{
"name": "Fav Icon",
"description": "http://stackoverflow.com/questions/14800881/not-allowed-to-load-local-resource-chrome-favicon",
"version": "1",
"manifest_version": 2,
"background": {
"scripts": [
"background.js"
]
},
"permissions": [
"tabs",
"<all_urls>"
]
}
background.js
chrome.tabs.query({
"active": true,//fetch active tabs
"currentWindow": true,//fetch tabs in current window
"status": "complete",//fetch completely loaded windows
"windowType": "normal"//fetch normal windows
}, function (tabs) {
for (tab in tabs) {
console.log(tabs[tab].favIconUrl);// Use this URL as needed
}
});
chrome.tabs.query will work on sub pages, if you want to use in content scripts use message passing to link with url.
Links
+3
source to share