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
請注意,權限不足,交叉來源問題等通常以類似的方式存在。沒有明顯的錯誤,沒有警報,沒有「未定義」的麻煩,只是代碼根本不起作用 - 這是權限問題的一個好兆頭。 –