在我的 manifest.json 中,当我添加背景属性时,弹出窗口不起作用(当我单击扩展名时没有任何反应),但是当我摆脱背景属性时,弹出窗口开始工作。我不知道为什么会这样。我在下面发布清单:
{
"manifest_version": 2,
"name": "Test blocking of 9gag",
"description": "my test shittt",
"version": "1.0",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"permissions": ["webRequest","webRequestBlocking","*://9gag.com/*"]
,
"background": {
"persistent": true,
"scripts": [ "block.js" ]
}
}
更新:添加了其他文件后台脚本:block.js:
chrome.webRequest.onBeforeRequest.addListener(
function(details) {
return {redirectUrl: "https://lh6.googleusercontent.com/-A3P-CvVSIyo/USzTbs0RRBI/AAAAAAAAALg/x47zbfBbYtw/s1600-rw/y-u-no-work"}
},
{urls: ["<all_urls>"]},
["blocking"]);
popup.html:
<!doctype html>
<html>
<head>
<title>test</title>
<style>
body {
min-width: 357px;
overflow-x: hidden;
}
img {
margin: 5px;
border: 2px solid black;
vertical-align: middle;
width: 75px;
height: 75px;
}
</style>
</head>
<body>
<div id="result"></div>
<p>Test.</p>
<p>test123</p>
</body>
</html>