简体   繁体   English

更改HTTP请求标头(用户代理) - Chrome / Firefox

[英]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. 使用Chrome / Firefox扩展程序更改/欺骗用户代理的最佳方法是什么?

Yes, I know the way to do it with config, but this isn't the perfect way. 是的,我知道用config做的方法,但这不是完美的方式。 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. 在Firefox中,在about:config设置general.useragent.override (确保它的类型为“string”)或者(不运行Firefox)将配置文件的“prefs.js”文件设置为所需的字符串。 A blank string results in no user-agent header being sent. 空白字符串不会导致发送用户代理标头。

In Chrome or Chromium, run the program with the argument --user-agent="STRING" . 在Chrome或Chromium中,使用参数--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 . 请注意,在这两种情况下都不会屏蔽来自Javascript的user-agent observable的位,例如navigator.userAgentnavigator.vendor Some Firefox extensions do change some of these; 一些Firefox扩展确实改变了其中一些; I think "User-Agent Switcher" and "TorButton" have code to do so. 我认为“User-Agent Switcher”和“TorButton”都有代码可以这样做。 Others do not, like UAControl. 其他人不像UAControl那样。 I don't know if Chrome exposes an API to its extensions for to mask those values. 我不知道Chrome是否会向其扩展程序公开API以屏蔽这些值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 某些网站仅在 Linux 上的 Firefox 中返回禁止响应(尽管将用户代理更改为 Chrome 有效); 常见的原因? - Some websites return a forbidden response only in Firefox on Linux (changing the user agent to Chrome works though); common cause? 使用AngularJS在Firefox中更改请求标头时遇到问题 - trouble changing request headers in Firefox with AngularJS 启用带有HTTP标头的最新Chrome和Firefox中的混合内容加载 - Enable mixed content loading in latest Chrome and firefox with http headers 为什么Chrome或Firefox不显示未决请求的请求标头? - Why doesn't Chrome or Firefox show request headers for pending requests? 在不使用插件的情况下向 Firefox HTTP 请求添加标头 - Adding Headers to Firefox HTTP Request without Using PlugIns Chrome或FireFox可以强制执行https请求而不是http请求吗? - Can Chrome or FireFox force https request instead of http request? 在Firefox中更新用户代理 - Update User Agent in Firefox HTTP DELETE请求产生的状态501未在Google chrome和firefox中实现 - HTTP DELETE request produces status 501 not implemented in google chrome and firefox htaccess,用户代理字符串和Firefox - htaccess, user agent string and firefox Firefox 中的用户代理 iOS iPhone - User agent iOS iPhone in Firefox
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM