help!!
this is what i have in my javascript file and i am not sure why it is not working. i am trying to set a background image on refresh and tab change. the changing of the background seems to work but the other part does not. anything helps. thanks
browser.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
// Check if the tab is the active tab and if its status has changed to "complete"
if (tab.active && changeInfo.status === "complete") {
// Tab has been refreshed, do something here
if (isBackgroundOn == true) {
toggleBgButton.textContent = "Turn Background Off";
changeBackground();
} else {
toggleBgButton.textContent = "Turn Background On";
changeBackground();
}
} else {
if (isBackgroundOn == true) {
toggleBgButton.textContent = "Turn Background Off";
changeBackground();
} else {
toggleBgButton.textContent = "Turn Background On";
changeBackground();
}
}
});
function changeBackground() {
browser.tabs.query({ active: true, currentWindow: true }).then((tabs) => {
// Execute the content script that will change the background image
browser.tabs.executeScript(tabs[0].id, {
code: `
document.body.style.backgroundImage = 'url("https://picsum.photos/1440/900")';
`
});
});
}
this is what i have in my manifest file
{
"manifest_version": 2,
"name": "custom chess.com themes",
"version": "1.0",
"description": "personilize your chess.com theme",
"icons": {
"48": "icons/icon48.png"
},
"browser_action": {
"default_icon": "icons/icon48.png",
"default_popup": "popup.html"
},
"permissions": [
"storage",
"activeTab"
],
"browser_specific_settings": {
"gecko": {
"id": "[email protected]",
"strict_min_version": "42.0"
}
},
"background": {
"scripts": ["assets/js/popup.js"],
"persistent": true
}
}