I got a little stuck here and wondered if anyone could point out where I might be wrong.
I'm just trying to make the body color change red when I click the application icon.
manifest.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 () {
background.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'"}); });
any ideas what i can do wrong? Thanks for taking the time to read this.
google-chrome google-chrome-extension google-chrome-app
Baconjuice
source share