コードの問題
"permissions": ["chrome://favicon/"]
、マニフェスト ファイルの無効なパターンです
タブの URL を使用する場合はfavicon
、拡張ページで chrome.tabs API を使用します。
デモンストレーション
マニフェスト.json
背景ページを登録し、必要な権限を追加しました。
{
"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 は拡張ページで機能します。コンテンツ スクリプトで使用する場合は、メッセージ パッシングを使用して URL を通信します。
参考文献