我有点卡在这里,想知道是否有人能指出我可能错在哪里。
我只是想在单击应用程序图标时使主体颜色变为红色。
清单.json
{
"name": "Bagde",
"description": "",
"version": "1",
"manifest_version": 2,
"background": {
"scripts": [
"background.js"
]
},
"browser_action": {
"default_title": "Test",
"default_popup": "popup.html"
}
}
popup.html
<html>
<head>
<script src="popup.js"></script>
</head>
<body>
<p>Some Content ..</p>
</body>
</html>
popup.js
document.addEventListener("DOMContentLoaded", function () {
//Get Reference to Functions
backGround = chrome.extension.getBackgroundPage();
//Call Function
backGround.updateIcon();
});
背景.js
var i = 1;
function updateIcon() {
i = 1;
chrome.browserAction.setBadgeText({
text: 'Test'
});
chrome.browserAction.setPopup({
popup: "popup.html"
});
}
chrome.browserAction.setBadgeBackgroundColor({
color: [200, 0, 0, 100]
});
window.setInterval(function () {
chrome.browserAction.setBadgeText({
text: String(i)
});
i++;
}, 4000);
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.executeScript(null,
{code:"document.body.bgColor='red'"});
});
任何想法我可能做错了什么?感谢您花时间阅读本文。