More testing, and changes & finally got it to work.
Seems you can't fetch from a content script?
anyhoo, if anyone else needs this... it seems to be workin
content script
async function refresh() {
browser.runtime.sendMessage({
status: "load"
});
setTimeout(refresh,30000); // 30 sec
};
refresh();
background script
browser.runtime.onInstalled.addListener(() => {
function handleMessage(request) {
let url = "https://www.bungie.net/Platform/Settings";
fetch(url)
.then(res => res.json())
.then(data => {
let c = data.Response.systems.Destiny2;
let msg = c.enabled ? "up" : "down";
if( msg === "up" ) {
browser.browserAction.setIcon({
path: "icons/leaf-64.png"
});
}
else if ( msg === "down" ){
browser.browserAction.setIcon({
path: "icons/redleaf-64.png"
});
}
})
.catch(err => {
});
};
browser.runtime.onMessage.addListener( handleMessage );
});