I'm trying to migrate an extension which uses the webRequest API from manifest v2 to v3 for both Firefox and Chrome. While it works as expected in Chrome, I can't get the webRequest API to work in Firefox with v3. I don't get any error messages, the callback for the onBeforeRequest event just never gets called. Here is a minimal example for Firefox:
v2 working webRequest API
manifest v2
{
"manifest_version": 2,
"name": "fun",
"version": "4.0.0",
"background":
{
"scripts": ["background.js"],
"type": "module"
},
"permissions":
[
"webRequest",
"<all_urls>"
]
}
background.js
let callbackFilter = { types: ["main_frame", "sub_frame", "xmlhttprequest", "websocket"], urls: ["<all_urls>"] };
console.log("Background script loaded");
browser.webRequest.onBeforeRequest.addListener(() => {
console.log("Received request event");
}, callbackFilter, []);
v3 not working in Firefox
{
"manifest_version": 3,
"name": "fun",
"version": "4.0.0",
"background":
{
"scripts": ["background.js"],
"type": "module"
},
"permissions":
[
"webRequest"
],
"host_permissions": ["<all_urls>"]
}