Joe Doe
Joe Doe

Reputation: 3692

Changing HTTP request headers (user agent) - Chrome/Firefox

I've googled, but I couldn't find anything. What would be the best way to change/spoof user agent with a Chrome/Firefox extension.

Yes, I know the way to do it with config, but this isn't the perfect way. Is there a way to stop request being sent, replace header and send it?

Upvotes: 5

Views: 5827

Answers (1)

Anonymous
Anonymous

Reputation: 50369

In Firefox, set general.useragent.override in about:config (make sure it's of type "string") or (without Firefox running) your profile's "prefs.js" file to the desired string. A blank string results in no user-agent header being sent.

In Chrome or Chromium, run the program with the argument --user-agent="STRING". A blank string results in a blank user-agent header being sent.

Note that in neither case does this mask the bits of the user-agent observable from Javascript, like navigator.userAgent or navigator.vendor. Some Firefox extensions do change some of these; I think "User-Agent Switcher" and "TorButton" have code to do so. Others do not, like UAControl. I don't know if Chrome exposes an API to its extensions for to mask those values.

Upvotes: 4

Related Questions