I'm retrieving some images from one of my chrome extension folders to the website DOM and everytime I reload the extension I'm getting a 'Extension Context Invalidated' error. Same thing happens when I do a 'chrome.storage.local.set'.
Doing some research I have realized that this error has to do with the facts well explained on this answer but since I'm not messaging between my content script and the background.js I wonder why this happens.
This is the part of my script (injected via chrome.tabs.executeScript in the popup.js) where I'm getting the error, I'm basically injecting images from one of my extension folders to the website DOM:
for (let k = 0; k < incomingChatTags.length; k++) {
let normalHolderTag = $(incomingChatTags[k]).text().toLowerCase();
switch (normalHolderTag) {
case "vip":
$(incomingChatTags[k]).addClass("ce-vip");
priorityVal += 300;
break;
case "rg":
$(incomingChatTags[k]).addClass("ce-rg");
priorityVal += 240;
break;
case "accountclosure":
$(incomingChatTags[k]).addClass("ce-accountclosure");
priorityVal += 200;
break;
case "21com":
let logo21 = chrome.extension.getURL("/images/21_thumb.png");
$(incomingChatTags[k]).html('<img src="' + logo21 + '" />');
$(incomingChatTags[k]).addClass("ce-tag-logo");
break;
case "caxino":
//the console shows the error here and not before....¿why?
let logoCaxino = chrome.extension.getURL(
"/images/caxino_thumb.png"
);
$(incomingChatTags[k]).html('<img src="' + logoCaxino + '" />');
$(incomingChatTags[k]).addClass("ce-tag-logo");
break;
case "justspin":
let logoJustSpin = chrome.extension.getURL(
"/images/wildz_thumb.png"
);
$(incomingChatTags[k]).html('<img src="' + logoJustSpin + '" />');
$(incomingChatTags[k]).addClass("ce-tag-logo");
break;
case "neonvegas":
let logoNeonVegas = chrome.extension.getURL(
"/images/neonVegas_thumb.jpg"
);
$(incomingChatTags[k]).html('<img src="' + logoNeonVegas + '" />');
$(incomingChatTags[k]).addClass("ce-tag-logo");
break;
case "nitrocasino":
let logoNitroCasino = chrome.extension.getURL(
"/images/nitroCasino_thumb.jpg"
);
$(incomingChatTags[k]).html(
'<img src="' + logoNitroCasino + '" />'
);
$(incomingChatTags[k]).addClass("ce-tag-logo");
break;
case "snabbis":
let logoSnabbis = chrome.extension.getURL(
"/images/snabbis_thumb.png"
);
$(incomingChatTags[k]).html('<img src="' + logoSnabbis + '" />');
$(incomingChatTags[k]).addClass("ce-tag-logo");
break;
case "sb.bet":
let logoSB = chrome.extension.getURL("/images/sb_thumb.png");
$(incomingChatTags[k]).html('<img src="' + logoSB + '" />');
$(incomingChatTags[k]).addClass("ce-tag-logo");
break;
case "wildz":
let logoWildz = chrome.extension.getURL("/images/wildz_thumb.png");
$(incomingChatTags[k]).html('<img src="' + logoWildz + '" />');
$(incomingChatTags[k]).addClass("ce-tag-logo");
break;
case "wishmaker":
let logoWishMaker = chrome.extension.getURL(
"/images/wishmaker_thumb.png"
);
$(incomingChatTags[k]).html('<img src="' + logoWishMaker + '" />');
$(incomingChatTags[k]).addClass("ce-tag-logo");
break;
}
$(incomingChat).attr("data-priority", priorityVal);
$(incomingChat).find(".numbers_cell").text(priorityVal);
}
from Chrome Extension: Extension context invalidated when getting URL
No comments:
Post a Comment