When making a chrome extension, I keep getting this error
Uncaught (in promise) Error: Could not establish connection. Receiving end does not exist.
Along with
background.js:0 (anonymous function)
Does anyone know how I could resolve this? I literally have like 3 lines in both my files.
This is my background.js file
chrome.tabs.onUpdated.addListener((tabId, tab) => {
if (tab.url && tab.url.includes("linkedin.com/in")) {
chrome.tabs.sendMessage(tabId, {type: "MAIN", profile: "test"});
}
});
and This is my ContentScript.js file
(() => {
chrome.runtime.onMessage.addListener((obj, sender, response) => {
//const { type, profile } = obj;
response = {line1 : "hello"}
});
})();
Any help would grealy be appreciated :)