我正在构建Chrome扩展程序,并希望在用户单击Chrome中的浏览器操作图标时显示弹出窗口并运行脚本。
我可以通过在manifest.json中放置'“ default_popup”:“ popup.html”'来使弹出窗口发生。但是,当我这样做时,background.js似乎没有运行。当我删除'“ default_popup”:“ popup.html”'时,background.js似乎正在运行。
如何同时显示弹出窗口和脚本?
manifest.json
{
"manifest_version": 2,
"name": "Typo Blaster",
"description": "Blast away typos and make the internet a safer place for the kids.",
"version": "0.1",
"browser_action": {
"default_icon": "icon.png",
"default_title": "Blast the typo!",
"default_popup": "popup.html"
},
"permissions": [
"activeTab"
],
"background": {
"scripts": ["background.js"],
"persistent": false
},
"icons": { "16": "icon16.png",
"48": "icon48.png",
"128": "icon128.png" }
}
Run Code Online (Sandbox Code Playgroud)
popup.html
<!doctype html>
<html>
<head>
<title>Typo Blaster</title>
<style>
body {
min-width: 357px;
overflow-x: hidden;
}
img {
margin: …Run Code Online (Sandbox Code Playgroud)