I've known how to add context-menuitem to firefox.

I frequently toggle Edit->Preferences->Advanced->Network->No Proxy | Manual proxy configuration

I want to add a Proxy ON/OFF to context-menu, it'll help me a lot.
I don't want to install another add-on to do this tiny job.
Is there a quick way? Thanks for your help!


If you don't want to install the excellent Toggle Proxy add-on (which gives you a keyboard shortcut and a toolbar button), you can go to the special URL about:config and change the value of network.proxy.type according to this article:

  • 0 - Direct connection, no proxy
  • 1 - Manual proxy configuration
  • 2 - Proxy auto-configuration (PAC)
  • 4 - Auto-detect proxy settings
  • 5 - Use system proxy settings (default on all platforms)

Specifically, it sounds like you will be toggling between 5 and 0.


As what I did in how to add context-menuitem to firefox.
I've added Toggle Proxy:

      <menuitem id="context-toggle-proxy"
                label="Toggle Proxy"
                oncommand="gPrefService.setIntPref('network.proxy.type', !gPrefService.getIntPref('network.proxy.type'));"/>

Currently, I'm working on how to display Proxy ON/Proxy OFF depending on current proxy setting.
If you have any idea, please let me known.


You should enable/disable an add-on to reload omni.ja.
Because I've wasted one hour on this.

  • Note that !gPrefService.getIntPref('network.proxy.type') will toggle Boolean values, which probably get cast to 0 and 1. It's probably better to use (gPrefService.getIntPref('network.proxy.type') == 0) ? 1 : 0, the ternary operator. The 1 you should use to specify the type when proxy is on, as in Alex's answer. – Bob May 8 '12 at 5:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.