FoxyProxy

ProxyConfigs Object

A container of ProxyConfig objects. It is used to add, edit, and delete one or more of them. This is a singleton.

Properties

length

NameTypeDescriptionSinceRequires
lengthIntegerGets the number of ProxyConfig objects.Basic: 2.6
Standard: 3.6
Plus: 4.6
Gecko 2+ (Firefox 4+, Thunderbird 3.3+, SeaMonkey 2.1+)

Examples

Get the Number of ProxyConfigs

    if (typeof(FoxyProxy) == "undefined")
      alert("Please install FoxyProxy Basic 2.6+, Standard 3.6+, or Plus 4.6+");
    else if (FoxyProxy.apiDisabled)
      alert("I cannot inspect FoxyProxy because the FoxyProxy API is disabled on your system.");
    else {
      FoxyProxy.getProxyConfigs({
        success: function(proxyConfigs) {
          alert("There are " + proxyConfigs.length + " proxy configurations");
        },
        error: function(msg) {
          alert("Error: " + msg);
        },
        rejected: function rejectedByUser() {
          alert("Please allow me to read/write FoxyProxy settings. Please try again and click the 'Allow' button.");
        }   
      });
       

Methods

createProxyConfig()

NameDescriptionSinceRequires
ProxyConfig createProxyConfig()Creates and return a new ProxyConfig with smart defaults. After creating a ProxyConfig, manipulate its properties and then pass it to addProxyConfig() to add it to the current list of proxies.Basic: 2.6
Standard: 3.6
Plus: 4.6
Gecko 2+ (Firefox 4+, Thunderbird 3.3+, SeaMonkey 2.1+)

Examples

Create and add a new ProxyConfig

    if (typeof(FoxyProxy) == "undefined")
      alert("Please install FoxyProxy Basic 2.6+, Standard 3.6+, or Plus 4.6+");
    else if (FoxyProxy.apiDisabled)
      alert("I cannot inspect FoxyProxy because the FoxyProxy API is disabled on your system.");
    else
      FoxyProxy.getProxyConfigs({
        success: function(pc) {
          // User agreed to let us change his settings.
          // Create new ProxyConfig
          var p = pc.createProxyConfig(); 
          // Set some values on it
          p.name = "Local Proxy";
          p.notes = "My Local Proxy Server;
          p.color = "#00FF00"; // green
          p.manualConfig.host = "192.168.1.1";
          p.manualConfig.port = "1010";
          p.mode = "manual";
          // Add it to FoxyProxy
          if (pc.addProxyConfig(p, idx))
            alert("Success");
          else
            alert("Unable to add ProxyConfig");
        },
        error: function(msg) {
          alert("Error: " + msg);
        },
        rejected: function rejectedByUser() {
          // User didn't allow us to make changes to FoxyProxy
          alert("Please allow me to add a new proxy to FoxyProxy. Please try again and click the 'Allow' button.");
        }   
      });
        

addProxyConfig()

NameDescriptionSinceRequires
boolean addProxyConfig(proxyConfig, index)Adds the specified ProxyConfig to the list of proxies. If index is not specified, the ProxyConfig is added to the top/front of the list (index 0). Otherwise, it is added at the specified zero-based index. index can also be one of the following words: first (index 0), last (number of proxies - 1), or random. If random, the proxy is added to the list of proxies at a random index. If index is neither a number nor one of those words, 0 is assumed.

true is returned if the proxy is successfully added; false otherwise. For example, passing an index out-of-bounds would yield a false return.

An "empty" ProxyConfig can be created using createProxyConfig(). Create the ProxyConfig, manipulate its properties, then call this function to add it to the list of ProxyConfigs.
Basic: 2.6
Standard: 3.6
Plus: 4.6
Gecko 2+ (Firefox 4+, Thunderbird 3.3+, SeaMonkey 2.1+)

Examples

Create and add a new ProxyConfig

    if (typeof(FoxyProxy) == "undefined")
      alert("Please install FoxyProxy Basic 2.6+, Standard 3.6+, or Plus 4.6+");
    else if (FoxyProxy.apiDisabled)
      alert("I cannot inspect FoxyProxy because the FoxyProxy API is disabled on your system.");
    else
      FoxyProxy.getProxyConfigs({
        success: function(pc) {
          // User agreed to let us change his settings.
          // Create new ProxyConfig
          var p = pc.createProxyConfig(); 
          // Set some values on it
          p.name = "Local Proxy";
          p.notes = "My Local Proxy Server;
          p.color = "#00FF00"; // green
          p.manualConfig.host = "192.168.1.1";
          p.manualConfig.port = "1010";
          p.mode = "manual";
          // Add it to FoxyProxy
          if (pc.addProxyConfig(p, idx))
            alert("Success");
          else
            alert("Unable to add ProxyConfig");
        },
        error: function(msg) {
          alert("Error: " + msg);
        },
        rejected: function rejectedByUser() {
          // User didn't allow us to make changes to FoxyProxy
          alert("Please allow me to add a new proxy to FoxyProxy. Please try again and click the 'Allow' button.");
        }   
      });
        

getAll()

NameDescriptionSinceRequires
ProxyConfig[] getAll()Returns an array of all ProxyConfig objects. The properties of each array element can be changed. Changes take immediate affect. Adding/removing items to/from the array has no effect. Use addProxyConfig() and deleteById() for those behaviors.Basic: 2.6
Standard: 3.6
Plus: 4.6
Gecko 2+ (Firefox 4+, Thunderbird 3.3+, SeaMonkey 2.1+)

Examples

Get all ProxyConfig objects and change the port of the first

    if (typeof(FoxyProxy) == "undefined")
      alert("Please install FoxyProxy Basic 2.6+, Standard 3.6+, or Plus 4.6+");
    else if (FoxyProxy.apiDisabled)
      alert("I cannot inspect FoxyProxy because the FoxyProxy API is disabled on your system.");
    else
      FoxyProxy.getProxyConfigs({
        success: function(pc) {
          // User agreed to let us change his settings.
          // Get all ProxyConfig objects
          var pcArray = pc.getAll(); 
          // Change the port of the first one. There is *always* a proxyConfig at index 0.
          pcArray[0].manualConfig.port = "9090";
          alert("Changed port of proxy '" + pcArray[0].name + "' to 9090");
        },
        error: function(msg) {
          alert("Error: " + msg);
        },
        rejected: function rejectedByUser() {
          // User didn't allow us to make changes to FoxyProxy
          alert("Please allow me to add a new proxy to FoxyProxy. Please try again and click the 'Allow' button.");
        }   
      });
        

getById()

NameDescriptionSinceRequires
ProxyConfig getById(id)Every ProxyConfig object has a unique id. This function gets the ProxyConfig with the specified id, or null if no such ProxyConfig exists. The properties of the returned ProxyConfig can be changed. Changes take immediate affect. This function is useful if you already know the id of the ProxyConfig to edit.Basic: 2.6
Standard: 3.6
Plus: 4.6
Gecko 2+ (Firefox 4+, Thunderbird 3.3+, SeaMonkey 2.1+)

Examples

Get a ProxyConfig object and change its PAC URL

    if (typeof(FoxyProxy) == "undefined")
      alert("Please install FoxyProxy Basic 2.6+, Standard 3.6+, or Plus 4.6+");
    else if (FoxyProxy.apiDisabled)
      alert("I cannot inspect FoxyProxy because the FoxyProxy API is disabled on your system.");
    else
      FoxyProxy.getProxyConfigs({
        success: function(pc) {
          // User agreed to let us change his settings.
          // Get the ProxyConfig object with id 1878135280
          var pc = pc.getById("1878135280"); 
          if (pc) {
            // Change the PAC URL
            pc.autoConfig.url = "https://mydomain.com/proxy.pac";
            alert("Changed PAC URL of proxy '" + pc.name + "' to https://mydomain.com/proxy.pac");
          }
          else
            alert("There is no proxy configuration with id 1878135280");      
        },
        error: function(msg) {
          alert("Error: " + msg);
        },
        rejected: function rejectedByUser() {
          // User didn't allow us to make changes to FoxyProxy
          alert("Please allow me to add a new proxy to FoxyProxy. Please try again and click the 'Allow' button.");
        }   
      });
        

getByIndex()

NameDescriptionSinceRequires
ProxyConfig getByIndex(idx)This function gets the ProxyConfig at the specified zero-based index, or null if no such ProxyConfig exists. The properties of the returned ProxyConfig can be changed. Changes take immediate affect. This function is useful if the index of the ProxyConfig to edit is already known.Basic: 2.6
Standard: 3.6
Plus: 4.6
Gecko 2+ (Firefox 4+, Thunderbird 3.3+, SeaMonkey 2.1+)

Examples

Get a ProxyConfig object and change its PAC URL

    if (typeof(FoxyProxy) == "undefined")
      alert("Please install FoxyProxy Basic 2.6+, Standard 3.6+, or Plus 4.6+");
    else if (FoxyProxy.apiDisabled)
      alert("I cannot inspect FoxyProxy because the FoxyProxy API is disabled on your system.");
    else
      FoxyProxy.getProxyConfigs({
        success: function(pc) {
          // User agreed to let us change his settings.
          // Get the ProxyConfig object at 3rd position
          var pc = pc.getByIndex(2); // zero-based
          if (pc) {
            // Change the PAC URL
            pc.autoConfig.url = "https://mydomain.com/proxy.pac";
            alert("Changed PAC URL of proxy '" + pc.name + "' to https://mydomain.com/proxy.pac");
          }
          else
            alert("There is no proxy configuration at the 3rd position");
        },
        error: function(msg) {
          alert("Error: " + msg);
        },
        rejected: function rejectedByUser() {
          // User didn't allow us to make changes to FoxyProxy
          alert("Please allow me to add a new proxy to FoxyProxy. Please try again and click the 'Allow' button.");
        }   
      });
        

getByName()

Not yet implemented.

deleteById()

Not yet implemented.