google-chrome-extension - Chrome 扩展程序无响应(browser_action 和后台脚本)
问题描述
知道为什么单击复选框时以下 chrome 扩展响应非常慢吗?
我尝试使用 page_action,但这阻止了该chrome.browserAction.setBadgeBackgroundColor
功能。
我想从 background.js 脚本更改扩展程序的图标,但是 options.html 不能正常工作。
清单.json:
{
"name": "name",
"description": "desc",
"manifest_version" : 2,
"version" : "0.1.0",
"icons": {
},
"web_accessible_resources": [
],
"options_page": "options.html",
"background": {
"scripts": ["background.js"],
"persistent": false
},
"browser_action": {
"default_title": "def title",
"default_popup": "options.html"
},
"permissions": [
"background",
"notifications",
"http://*/",
"https://*/"
]
}
选项.html:
<!DOCTYPE HTML>
<html>
<head>
<title>Title</title>
</head>
<body>
<div>
<div class="p-2">
<form>
<div>
<input type="text" name="input_text" id="input_text" />
<label for="input_text">Text input</label>
</div>
<div>
<input type="checkbox" name="cb1" id="cb1" />
<label for="cb1">Checkbox 1</label>
</div>
<div>
<input type="checkbox" name="cb2" id="cb2" />
<label for="cb2">Checkbox 2</label>
</div>
<div>
<input type="submit" name="submit" value="Submit"/>
</div>
</form>
</div>
</div>
</body>
</html>
背景.js:
function changeIconBackground() {
chrome.browserAction.setBadgeBackgroundColor({color: [255, 255, 0, 200]});
}
changeIconBackground();
解决方案
推荐阅读
- reactjs - 根据道具值显示组件反应
- google-cloud-platform - 无法开始在 Web UI 上训练我的 GCP AutoML 实体提取模型
- asp.net-core - Blazor 参数是否会带来额外的开销?
- clickhouse - Clickhouse - 输出每个数组项及其索引/位置
- r - R代码将列转为行,将行转为列
- javascript - Firebase Node.js 本地测试凭证与功能
- html - 每当屏幕在引导程序中变为中等时,我的列就会消失
- java - Spring boot:将类转换为bean
- javascript - 在使用 javascript 呈现的选择字段上出错,同时在烧瓶中提交表单
- sqlite - SQLite 查找来自用户输入的数据位于哪个表