title: Modify Request Body
body: <p>I'm trying to modify the request body of a request to show the research tool in Google docs. I'm able to trigger on each request that matches, and pull the form_data request body, but I don't see any way of modifying the request body and passing it on. All I need to do is change docs-show_reference to false.</p>
  
  <p>Blocking the request doesn't work, as the page then initiates the request again, leading to a loop. I can't seem to modify the request headers properly to block the request, as the only thing that needs to change is within the form_data request body. It also doesn't appear that it's at all possible to return modified request body through chrome.webRequest</p>
  
  <p>The extension also blocks all non-docs addresses (which is also working).</p>
  
  <p>Here's the code I'm using (that initiates the redirect loop). All the permissions and config in manifest.json is also working properly.</p>
  
  <pre><code>chrome.webRequest.onBeforeRequest.addListener(
    function(info) {
        var request = info.requestBody;
        if (info.url.indexOf(chrome.runtime.id) &gt; -1) {
            console.log("popup: %s",info.url);
            return;
        }
        if (info.url.indexOf("docs.google.com") &gt; -1){
            if (request &amp;&amp; request.formData &amp;&amp; request.formData.preferences &amp;&amp; request.formData.preferences[0] == '{"docs-show_reference":true}') {
  
               return {cancel:true};
            } else {
              return {cancel:false};
            }
        }
        if (info.url.indexOf('gstatic') &gt; -1) {
            return {cancel:false};
        }
  
        console.log("blocked: %s",info.url);
        return {redirectUrl:chrome.extension.getURL("blocked.png")};
    },
    // filters
    {
      urls: [
        "&lt;all_urls&gt;"
      ]
    },
    // extraInfoSpec
    ["blocking", "requestBody"]
  );
  </code></pre>