- 想要设置插件logo的bradege,报错:
(TypeError): Cannot call method 'setBadgeText' of undefined
//background.js
chrome.browserAction.setBadgeText({text: 'new'});
chrome.browserAction.setBadgeBackgroundColor({color: [255, 0, 0, 255]});
报错,(TypeError): Cannot call method 'setBadgeText' of undefined
原因:
我的manifest.json 设置的是:page_action
"page_action": {
"default_popup": "popup.html",
"default_icon": {
"16": "images/get_started16.png",
}
}
应该修改为browser_action:
"browser_action":
{
"default_icon": "images/get_started16.png",
"default_title": "这是一个示例Chrome插件",
"default_popup": "popup.html"
},
2.引入外链资源
报错:
需要在manifest.json文件中加入配置:
"content_security_policy": "script-src 'self' https://example.com; object-src 'self'",
参考
官方文档:https://developer.chrome.com/extensions/pageAction
🌟开发全攻略:
https://www.cnblogs.com/liuxianan/p/chrome-plugin-develop.html
http://blog.haoji.me/chrome-plugin-develop.html
Chrome 插件开发入门:https://crxdoc-zh.appspot.com/extensions/getstarted
Chrome 网站获取cookie:https://segmentfault.com/a/1190000020525962