Рабочий код.
function changeProxy (currentIP, currentPort) { // Добавляет прокси в настройках Firefox
var iphttp= currentIP;
var ipssl= currentIP;
var ipftp= '';
var ipsocks= '';
var socksver= '5';
var portall= currentPort;
var logAndPassProxy = '';
var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
// manual proxy configuration
prefs.setIntPref("network.proxy.type", 1);
// use the proxy server for all protocols
prefs.setBoolPref("network.proxy.share_proxy_settings", true);
// each proxy independent
prefs.setBoolPref("network.proxy.share_proxy_settings", false);
// HTTP Proxy
prefs.setCharPref("network.proxy.http", iphttp);
prefs.setIntPref("network.proxy.http_port", portall);
// SSL Proxy
prefs.setCharPref("network.proxy.ssl", ipssl);
prefs.setIntPref("network.proxy.ssl_port", portall);
// FTP Proxy
prefs.setCharPref("network.proxy.ftp",ipftp);
prefs.setIntPref("network.proxy.ftp_port",portall);
// SOCKS Host
prefs.setCharPref("network.proxy.socks", ipsocks);
prefs.setIntPref("network.proxy.socks_port", portall);
prefs.setIntPref("network.proxy.socks_version", socksver);
// login & password proxy
//prefs.setCharPref("extensions.proxyauth.authtoken",logAndPassProxy);
}
ip = "192.168.1.1";
port = "1234";
changeProxy (ip, port);