How can I spoof the user agent of a JavaScript GET request? setRequestHeader with User-Agent
isn't allowed:
xmlHttpRequest.setRequestHeader("User-Agent", "...");
The process is called user-agent spoofing. Yes, when a browser or any client sends a different user-agent HTTP header from what they are and fake it that is called spoofing.
User-Agents is a JavaScript package for generating random User Agents based on how frequently they're used in the wild. A new version of the package is automatically released every day, so the data is always up to date.
What Is Browser Spoofing? Fraudster use browser spoofing to manipulate their browser to make it seem as if they are using a different browser configuration which they would use regularly, for example, to make it seems as if they're from a different country.
Yes its reliable for non hacker user. The user agent string is a text that the browsers themselves send to the webserver to identify themselves, so that websites can send different content based on the browser or based on browser compatibility.
In short: You can't due to built-in cross-domain limitations.
One way "around" that was to write a proxy-webservice and let the server spoof whatever headers you need spoofed.
You can't do this in a half-decent browser because of security issues surrounding it. You don't want XSS scripts to be changing request headers and running rampant on your site.
However I believe there's a workaround in IE if you use VBScript:
MyHttp.setRequestHeader "User-Agent", "MyCustomUser"
The alternative is to have a web page on your site dedicated to forwarding a GET request, changing the appropriate headers as necessary.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With