MDN wants to learn about developers like you: https://qsurvey.mozilla.com/s3/MDN-dev-survey

Add-ons

proxy.register()

Registers a Proxy Auto-Configuration (PAC) file. The file is executed immediately, and its FindProxyForURL() function will be called for any HTTP, HTTPS, or FTP requests.

If PAC files are registered by more than one extension, then requests will be passed initially to the one that was registered first.

  • If the FindProxyForURL() function in the first PAC returns "DIRECT" for a request, then the request will be passed unchanged to the FindProxyForURL() function in the next PAC.
  • If the FindProxyForURL() function in the first PAC proxies the request by returning "PROXY" or some other proxying value, then the proxy URL will be passed to the FindProxyForURL() function in the next PAC.

Each extension can only register a single PAC file: if you call register() twice, the second PAC file will replace the first.

This is an asynchronous function that returns a Promise.

Syntax

var registering = browser.proxy.register(
  url   // string
)

Parameters

url
String. URL pointing to the PAC file to load. PAC files must be bundled with the extension, and url must be relative to the extension's manifest.json file.

Return value

A Promise that will be fulfilled with no arguments when the PAC file has been registered, or rejected if there was an error.

Browser compatibility

ChromeEdgeFirefoxFirefox for AndroidOpera
Basic supportNoNo55 155No
1. Before version 56, this function was called 'registerProxyScript'

Examples

const proxyScriptURL = "proxy/proxy-script.js";

browser.proxy.register(proxyScriptURL);

Example extensions

Acknowledgements

Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.

Document Tags and Contributors

 Contributors to this page: wbamberg, andrewtruongmoz
 Last updated by: wbamberg,