Search code examples
firefoxproxyfirefox-3

How can I change Firefox's proxy settings from an external program?


I've seen a few programs (eg Charles Web Developer Proxy) that are able to modify Firefox's proxy settings. The sequence is:

  1. Firefox is running, with the users proxy settings.
  2. User starts the external third party application, which
  3. modifies Firefox's proxy settings, and then
  4. the user exits the third party program and,
  5. Firefox resumes running with its original proxy settings.

Assuming the external application is remembering the old proxy settings and restoring them on exit how can I read and write Firefox's proxy settings? Have tried Googling through the Firefox doco but no luck yet.

Options Considered:

  • Write a new user preferences config file and start a new instance of the browser. Would work but not quite right -- Charles for example can modify the settings of an already running browser and restore them without restarting.
  • Write a plug-in. Could write a Firefox plugin that offered some kind of IPC to the outside and then handled the Firefox preference setting itself. In fact, I think this might be the only way. Disabling Charles' Firefox plug-in seems to disable its ability to modify preferences on the fly.

Possible Resources


Solution

  • From what I could see from the documentation, Charles has a matching Firefox extension which it installs/uses. That may be how it can reload the proxy information on the fly.

    Proxy information is stored in your profile's prefs.js, but that can't be reloaded on the fly. Firefox reads from it on startup and writes to it when it shuts down, and does not load from it in between. Also, if Firefox is running when you edit prefs.js, your changes will be overwritten.

    I thought you might be able to do something with a PAC file, but after digging around a bit, I've found that it doesn't seem to be reloaded on the fly either. You'd have to restart to reload any modifications to the settings.