Hey, I’m trying to execute this script on Firefox 110:
browser.runtime.onMessage.addListener((id, info, tab) => {
if (info.status === 'loading') {
chrome.scripting.executeScript({
target: {tabId: id},
func: () =>
JSON.stringify({
url: window.location.href,
header: document.contentType,
loaded: !!window.state,
})
}, (res) => {
console.log(chrome.runtime.lastError)
})
}
but no matter what I try I cannot make it to believe me that the access to that origin was enabled. The error states that Missing host permission for the tab
which could have been helpful if it was true. So I tried any combination that I can think of: enabling the specific origin in host_permissions
, enabling all, adding *://*/
to optional_permissions
instead and then asking the user explicitly for access to that origin using the browser.permissions.request
API, and even if after all of that the permissions tab for the extension is clearly telling me that the access to that origin was enabled I just keep getting the Missing host permission for the tab
error.
So at this point I’m wondering if this API works in MV3 as it is stated in the official docs: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/scripting/executeScript ?
Thanks.