我正在制作检测某些域的扩展程序,并且它应该根据域名更改图标,灰色徽章,红色徽章或绿色徽章。
我试图使用内容脚本:
chrome.browserAction.setIcon({
path : {
"16": "icons/icon16.png",
"19": "icons/icon19.png",
"48": "icons/icon48.png"
}
});
问题是,它说chrome.browserAction未定义。
这是我的manifest.json
{
"name": "CHANGE THIS : Extension boilerplate",
"version": "0.1",
"manifest_version": 2,
"description": "This extension was created with the awesome extensionizr.com",
"homepage_url": "http://extensionizr.com",
"icons": {
"16": "icons/icon16.png",
"48": "icons/icon48.png",
"128": "icons/icon128.png"
},
"default_locale": "en",
"options_page": "src/options_custom/index.html",
"page_action": {
"default_icon": "icons/icon19.png",
"default_title": "page action demo",
"default_popup": "src/page_action/page_action.html"
},
"permissions": [
"http://*/*",
"https://*/*"
],
"content_scripts": [
{
"matches": [
"<all_urls>"
],
"css": [
"src/inject/inject.css"
]
},
{
"matches": [
"<all_urls>"
],
"js": [
"/js/jquery/jquery.min.js",
"src/inject/inject.js"
]
}
],
"web_accessible_resources": ["icons/stop.png"]
}
我可以显示初始图标,但我无法更改它。