proxy

翻译不完整。 请帮助我们翻译这篇文章!

Warning
You should not use proxy.register() function or the 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.

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

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).

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

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

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

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.

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

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.

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

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

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxOperaFirefox for Android
onErrorChrome No support NoEdge No support NoFirefox Full support 60
Full support 60
No support 55 — 71
Alternate Name
Alternate Name Uses the non-standard name: onProxyError
Opera No support NoFirefox Android Full support 60
Full support 60
Full support 55
Alternate Name
Alternate Name Uses the non-standard name: onProxyError
onRequestChrome No support NoEdge No support NoFirefox Full support 60Opera No support NoFirefox Android Full support 60
ProxyInfoChrome No support NoEdge No support NoFirefox Full support 60Opera No support NoFirefox Android Full support 60
RequestDetailsChrome No support NoEdge No support NoFirefox Full support 60Opera No support NoFirefox Android Full support 60
register
Deprecated
Chrome No support NoEdge No support NoFirefox No support 56 — 71
No support 56 — 71
Full support 55
Alternate Name
Alternate Name Uses the non-standard name: registerProxyScript
Opera No support NoFirefox Android Full support 56
Full support 56
Full support 55
Alternate Name
Alternate Name Uses the non-standard name: registerProxyScript
settingsChrome No support NoEdge No support NoFirefox Full support 60
Notes
Full support 60
Notes
Notes In version 59, this property was listed as proxyConfig in the browserSettings namespace, but it had a bug that made it mostly unusable.
Opera No support NoFirefox Android No support No
unregister
Deprecated
Chrome No support NoEdge No support NoFirefox No support 56 — 71Opera No support NoFirefox Android Full support 56

Legend

Full support  
Full support
No support  
No support
Deprecated. Not for use in new websites.
Deprecated. Not for use in new websites.
See implementation notes.
See implementation notes.
Uses a non-standard name.
Uses a non-standard name.