Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to change firefox proxy from addon

I can not change firefox proxy via the code below:

var scope = {};
Components.utils.import("resource://imacros/utils.js", scope);
Components.utils.import("resource://imacros/rijndael.js", scope);
Components.utils.import("resource://gre/modules/ctypes.jsm", scope);
var __loginf = scope.__loginf;
var imns = scope.imns;

var pref = imns.prefsvc.getBranch("network.proxy.");
pref.setCharPref("http", server);
pref.setIntPref("http_port", port);
pref.setCharPref("ssl", server);
pref.setIntPref("ssl_port", port);
pref.setIntPref("type", 1);

Help me please.

like image 973
user3363229 Avatar asked Mar 20 '23 10:03

user3363229


1 Answers

You should definitely be using the addon-sdk. Here's a link to their docs for the preferences service where you can find more info.

Here's what a solution could look like using the addon-sdk.

var prefsvc = require("sdk/preferences/service");
prefsvc.set("network.proxy.http", server);
prefsvc.set("network.proxy.http_port", port);
prefsvc.set("network.proxy.ssl", server);
prefsvc.set("network.proxy.ssl_port", port);
prefsvc.set("network.proxy.type", 1);
like image 141
Bryan Clark Avatar answered Apr 01 '23 19:04

Bryan Clark