OnBeforeRequest URL redirect in Firefox Addon (Conversion from Chrome Extension)
<p>I want to convert a Chrome extension of mine to Firefox. So far so good, except I had an url redirect in <code>webRequest.onBeforeRequest</code> in the Chrome extension, which is <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities#webRequest" rel="nofollow">not allowed in Firefox WebExtensions</a>. </p>

<p>Now I am unsure how to implement this in Firefox.<br>
In the Chrome <code>background.js</code> it looked something like this:</p>

<pre><code>chrome.webRequest.onBeforeRequest.addListener(
  function(details) {
    console.log('onBeforeRequest');

    var returnuri;
    returnuri = details.url;
    if ((details.url.indexOf("/malicious/") &gt; -1) || (details.url.indexOf("/bad/") &gt; -1)){
      //I want to redirect to safe content
      returnuri = details.url + (/\&amp;tag=/.test(details.url) ? "" : '/safe/');
    }else{
      returnuri = details.url;
    }
    return {redirectUrl: returnuri};
  },
  {
    urls: [
      "*://malicious.com/*"
    ],
    types: ["main_frame"]
  },
  ["blocking"]
);
</code></pre>