proxy

警告: 不推荐使用 proxy.register() 或者 proxy.unregister() 方法使用 Proxy Auto-Configuration (PAC) file. 这个 API 将会在 Firefox 68 中废弃并且在 Firefox 71 中删除。

使用 proxy API 来代理 web 请求。你可以使用 proxy.onRequest 事件监听器来拦截 web 请求,并且返回一个可以描述是否代理并且怎样代理它们的对象。

proxy.onRequest的好处在于,用于实现你拦截策略的代码在你的扩展的后台脚本运行,所以,它可以让 WebExtension APIs 能够完全的访问你的扩展 (举例来说,可以访问你扩展的storage和像 dns 等类似的网络 api)

除了这个 api,扩展也能够使用**browserSettings.proxyConfig**属性来重新编辑你全局的proxy设置

Chrome 浏览器提供了一个叫做'proxy'的api 扩展,它的功能跟这个 api 类似,在 chrome 的 api 中也可以用来实现一个拦截策略。然而,Chrome 的 API 的设计跟这个 API 设计完全不同。因为这个 API 跟谷歌的proxy的 API 完全不同,这个 API 只能通过'browser'命名空间访问

如果你想用这个 API 你需要得到'proxy'的permission.并且,如果你想拦截一个请求,你同样也需要当前拦截请求的 url 的 host permission

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() 已弃用

Registers the given proxy script.

proxy.unregister() 已弃用

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