Hello,
I’m doing some initial testing, for Manifest v3.
When I’m trying to executeScript from background, I get “Error: Missing host permission for the tab”
I have enabled scripting and activeTab, and everything I can think of.
What am I missing?
manifest.json
{
"name": "Hello, World!",
"version": "1.0",
"manifest_version": 3,
"background": {
"scripts": ["background.js"]
},
"permissions": [
"scripting",
"activeTab",
"tabs"
],
"host_permissions": ["<all_urls>", "*://*/*"],
"action": {},
"content_security_policy": {
"extension_pages": "script-src 'self'; object-src 'self'"
}
}
background.js
browser.runtime.onInstalled.addListener(async () => {
let url = browser.runtime.getURL("hello.html");
let tab = await browser.tabs.create({ url });
try {
await browser.scripting.executeScript({
target: {
tabId: tab.id,
},
func: () => {
console.log("injected");
},
});
} catch (err) {
console.error(`failed to execute script: ${err}`);
}
});