I am experimenting with Google Chrome Extensions and first problems I have is that I want to automaticly change body background color when page is loaded (without clicking on extension icon) but my content scripts are not firing up:
manifest.json:
{
"name": "Test Extension",
"description": "Testing",
"version": "1.0",
"permissions": [
"tabs", "webNavigation"
],
"browser_action": {
"default_title": "Set this page's color.",
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"content_scripts": [
{
"matches": ["http://*/*", "https://*/*"],
"js": ["core.js"]
}
],
"background": {
"scripts": ["background.js"]
},
"manifest_version": 2
}
core.js:
chrome.tabs.executeScript(null,{code:'document.body.style.backgroundColor = "green";'});
Not working solution background.js:
chrome.webNavigation.onHistoryStateUpdated.addListener(function(details) {
chrome.tabs.executeScript(null,{file:"core.js"});
});
Where is the problem? Please for help.