proxy 编辑

Warning
You should not use the proxy.register() or proxy.unregister() function to register and remove extended Proxy Auto-Configuration (PAC) file. This API was deprecated in Firefox 68 and will be removed from Firefox 71.

Use the proxy API to proxy web requests. You can use the proxy.onRequest event listener to intercept web requests, and return an object that describes whether and how to proxy them.

The advantage of the proxy.onRequest approach is that the code that implements your proxy policy runs in your extension's background script, so it gets full access to the WebExtension APIs available to your extension (including, for example, access to your extension's storage and networking APIs like dns).

Apart from this API, extensions can also use the browserSettings.proxyConfig property to configure global proxy settings.

Google Chrome provides an extension API also called "proxy" which is functionally similar to this API, in that extensions can use it to implement a proxying policy. However, the design of the Chrome API is completely different to this API. Because this API is incompatible with the Chrome proxy API, this API is only available through the browser namespace.

To use this API you need to have the "proxy" permission. Also, where you want to intercept requests, you also need host permission for the URLs of intercepted requests.

Types

proxy.ProxyInfo
Describes a proxy.
proxy.RequestDetails

Contains information about a web request that the browser is about to make.

Properties

proxy.settings
Get and set proxy settings.

Functions

proxy.register() This deprecated API should no longer be used, but will probably still work.
Registers the given proxy script.
proxy.unregister() This deprecated API should no longer be used, but will probably still work.
Unregisters the proxy script.

Events

proxy.onError
Fired when the system encounters an error running the PAC script or the onRequest listener.
proxy.onRequest
Fired when a web request is about to be made, giving the extension an opportunity to proxy it.

Example extensions

Browser compatibility

BCD tables only load in the browser

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:77 次

字数:6399

最后编辑:7 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文