0
我的Chrome扩展程序为灰色,弹出窗口不显示。我试图让它在“https://scratch.mit.edu”和所有子域上工作,但它在每个站点都是灰色的。弹出窗口也不显示在任何网站上。Chrome扩展程序为灰色,并且弹出窗口不显示
manifest.json的:
{
"manifest_version": 2,
"background": {
"page": "background.html"
},
"page_action": {
"default_icon": {
"19": "images/icon19.png",
"38": "images/icon38.png"
},
"default_title": "Scratch theme loader",
"default_popup": "popup.html"
},
"permissions": [
"storage",
"declarativeContent",
"https://scratch.mit.edu/*",
"https://pastebin.com/raw/*"
]
}
background.html:
<!DOCTYPE html>
<html>
<head>
<title>Background operation for Scratch Themes</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<script type="text/javascript">
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
if (tab.url.indexOf('https://scratch.mit.edu') > -1) {
chrome.pageAction.show(tabId);
} else {
chrome.pageAction.hide(tabId);
}
});
</script>
</body>
</html>
popup.html:
<!DOCTYPE html>
<html>
<head>
<title>Scratch Themes</title>
<style>
body {
min-width: 357px;
overflow-x: hidden;
font-family: "Segoe UI", "Lucida Grande", Tahoma, sans-serif;
font-size: 100%;
}
img {
align: center;
}
</style>
</head>
<body>
<ul>
<li>
<img src = "images/S_Themes.png">
</li>
<li>
<p>Choose which theme you would like to use:</p>
<form action="">
<input type="radio" name="example" value="1"> Example 1<br>
<input type="radio" name="example" value="2"> Example 2<br>
<input type="radio" name="example" value="3"> Example 3
</form>
</li>
</body>
</html>
感谢这工作得很好!我还必须更改权限才能添加“标签”。 – Melkor
请注意,权限不足,交叉来源问题等通常以类似的方式存在。没有明显的错误,没有警报,没有“未定义”的麻烦,只是代码根本不起作用 - 这是权限问题的一个好兆头。 –