简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM