I have to send message from content script to background, a i always got error Uncaught TypeError: Cannot read property 'sendMessage' of undefined
background script is unnecessary, because i have error in the content script
I checked chrome.extension.sendMessage
and the same error
content script:
try {
chrome.storage.sync.set({
"channelId": cid
});
} catch (error) {
if (toReload(error.toString())) {
chrome.runtime.sendMessage({ message: "errorreset" }, function (response) {
console.log(123);
});
}
}
manifest
"background": {
"page": "notifications.html",
"persistent": true
},
"content_scripts": [
{
"matches": ["*://*.youtube.com/*"],
"js": [
"lib/jquery-3.6.0.min.js",
"init.js"
],
"run_at": "document_idle",
"all_frames": true
}
],