Open paudsu01 opened 7 months ago
I am not sure how one could solve this, but the code would probably need to get all tabs like you do there but inject code again into them using chrome.tabs.executeScript
.
Fixed in #7 : Just like I had suggested earlier, the tabs where the content-script doesn't get loaded as it happens with the already open tabs when the extension gets loaded/installed needs the injection of content scripts.
So, chrome.scripting.executeScript
is used to execute the content-script (got changed from chrome.tabs.executeScript
since manifest v3) if the tab doesn't have the content-script loaded already.
try {
await chrome.tabs.sendMessage(tab.id, {
translate: boolean,
});}
catch(error) {
chrome.scripting.executeScript({
target: {tabId: tab.id, allFrames: true},
// location relative to root folder(where manifest.json is)
files: ['scripts/content.js'],
});
}
https://github.com/AbhishekTimalsina/Type-Nepali/blob/e0443ebda6d1daf9cb6856e1bca06b3a6757497f/scripts/popup.js#L26-L34
The line
await chrome.tabs.sendMessage(tab.id, {
translate: boolean,
raises theCould not establish connection. Receiving end does not exist.
error on some circumstances. This is most-likely because of the fact that chrome doesn't automatically re-inject the content scripts in the currently open tabs after the extension is updated/installed.