title: Changing User-Agent in XMLHttpRequest from a Chrome extension
body: <p>I'm trying to send a HTTP request from a Extension in which I need to change the User-Agent.</p>
  
  <p>My code looks like this:</p>
  
  <pre><code>function getXMLHttpRequest(method, url, extraHeaders) {
      var xhr = new XMLHttpRequest();
      xhr.open(method, url, true)
  
      for (var headerKey in extraHeaders) {
          xhr.setRequestHeader(headerKey, extraHeaders[headerKey]);
      }
  
      return xhr;
  }
  //....
  
  getXMLHttpRequest("POST", "....", { "User-Agent": "Blahblahblah" })
  </code></pre>
  
  <p>Then, I get an error <strong>"Refused to set unsafe header: UserAgent"</strong></p>
  
  <p>I need to change that because my Backend needs to have an special User-Agent, is it possible to do that from an extension?</p>
  
  <p>I tried webRequest API, to change the header before sending the request, but it says it does not work with XMLHttpRequest made from extensions in order to prevent locking.</p>