Is there any way to do this? I'm trying to send a GET request to a website, but I want to customize my UserAgent. Is there any way to do this in pure HTML and JavaScript? I'd like it to all execute locally.
The origin trial that allowed sites to test the fully reduced User-Agent will end on April 19, 2022. After that date, the User-Agent String will be gradually reduced. To review the whole schedule, see Chromium Blog: User-Agent Reduction Origin Trial and Dates.
The userAgent property returns the user-agent header sent by the browser to the server. The userAgent property is read-only. The value returned, contains information about the browser name, version and platform. The web specification suggests that browsers should provide as little header information as possible.
Select the “Advanced” tab and enable the “Show Develop menu in menu bar” option at the bottom of the window. Click Develop > User Agent and select the user agent you want to use in the list. If the user agent you want to use isn't shown here, select “Other” and you can provide a custom user agent.
This is working for me.
Object.defineProperty(navigator, 'userAgent', { get: function () { return 'Mozilla/5.0 (Windows NT 6.2; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0)'; } });
It is an updated version of code4coffee's answer as Object.prototype.__defineGetter__()
is deprecated: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/__defineGetter__
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