/* My Unique Background Code */
console.log("Initializing the Background ! ");
chrome.runtime.onMessageExternal.addListener(
(request, sender, sendResponse) => {
console.log("A message has been received");
console.log(request);
console.log(sender);
}
);
// Injecting script into the page
chrome.webNavigation.onCompleted.addListener((details) => {
chrome.tabs.executeScript(details.tabId, {
file: "include/ts/injectScript.js",
runAt: "document_end"
});
}, {url: [{urlPrefix: "https://website.com"}]});
console.log("Finished Initializing the Background");
/* My uniquely injected script code */
var extensionID = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
chrome.runtime.sendMessage(extensionID, {test : 123},(response) => {
console.log(response);
});
/* A snippet of my manifest.json file (with correct URL configuration) */
"externally_connectable": {
"matches": [
"*://*.example.com/tests/*"
]
},
"permissions": [..., "*://*.example.com/tests/*",...]
The background automatically injects a JS script when the page loads.
All tests conducted in the console (on the current page) are successful, and the background is able to receive messages.
Unfortunately, even though the background successfully injects the script upon page load, it is not receiving any messages.
Apologies for any language errors, Thank you in advance for your assistance
Jérémy-F