Can someone help me out? I keep on receiving the error messages
Unchecked runtime.lastError: Cannot access contents of url. Extension manifest must request permission to access this host.
and Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist.
in google chrome manifest 3.
Listening from content script
chrome.runtime.onMessage.addListener(
function(req, sender, sendResponse) {
if(req.msg === "analysis background") {
let obj = parse();
sendResponse(obj);
}
return true;
}
);
);
manifest.json
{
"manifest_version": 3,
"name": "extensionParser",
"version": "1.0.0",
"action": {
"default_popup": "popups/popup.html"
},
"background": {
"service_worker": "background.js"
},
"permissions": ["tabs", "scripting",
"http://localhost/site_for_parsing"]
}
Code snippet from background file
const siteUrl = "http://localhost/site_for_parsing";
chrome.runtime.onConnect.addListener(port => {
port.onMessage.addListener(msg => {
if(msg.message === 'analysis') {
chrome.tabs.create({active: false, url: siteUrl}, tab => {
chrome.scripting.executeScript({
target: {tabId:tab.id},
files: ['dist/parser.js']
}, (results) => {
chrome.tabs.sendMessage(tab.id, {msg: "analysis background"}, res => {
port.postMessage(res)
chrome.tabs.remove(tab.id)
})
})
});
}
});
});
I would greatly appreciate your assistance! Looking forward to your responses. Have a wonderful day!