I\'m trying to send a HTTP request from a Extension in which I need to change the User-Agent.
My code looks like this:
function getXMLHttpRequest(met
You can easily change the User-Agent header with the webRequest
API.
For sample code, see Associate a custom user agent to a specific Google Chrome page/tab.
Take the code from that answer, and change "main_frame", "sub_frame"
to "xmlhttprequest"
to modify network requests initiated via XMLHttpRequest
.
Obviously, to prevent deadlocks, this method does not work with synchronous requests ( i.e. when the third parameter of xhr.open
is set to false
).