When using browser.webRequest.onBeforeRequest
, I would like to return a redirect to an HTML file packaged in the extension.
I have the extension activated as a temporary extension.
Example of what I'm trying to accomplish:
let pattern = "https://developer.mozilla.org/*";
let targetUrl = "/src/index.html";
function redirect(requestDetails) {
return {
redirectUrl: targetUrl
};
}
browser.webRequest.onBeforeRequest.addListener(
redirect,
{urls: [pattern]},
["blocking"]
);
If I use an URL like https://example.com
, it works. I also tried to use tabs.update("/src/test.html")
inside the redirect
function, but no luck.
Do I need some permission for this?