title: Edit .js file from python
body: <p>I'm writing a program that involves editing Firefox's proxy settings, specifically the socks and http proxy settings. I want to do this through editing Firefox's prefs.js file. It opens just fine in python - but after that I just can't think of a way to do this that isn't incredibly long and roundabout. The part of prefs.js that I want to edit looks like this:</p>
  
  <pre><code>user_pref("network.proxy.backup.ftp", "");
  user_pref("network.proxy.backup.ftp_port", 0);
  user_pref("network.proxy.backup.socks", "");
  user_pref("network.proxy.backup.socks_port", 0);
  user_pref("network.proxy.backup.ssl", "");
  user_pref("network.proxy.backup.ssl_port", 0);
  user_pref("network.proxy.ftp", "foo.bar");
  user_pref("network.proxy.ftp_port", 5);
  user_pref("network.proxy.gopher", "");
  user_pref("network.proxy.gopher_port", 0);
  user_pref("network.proxy.http", "foo.bar");
  user_pref("network.proxy.http_port", 5);
  user_pref("network.proxy.share_proxy_settings", true);
  user_pref("network.proxy.socks", "foo.bar");
  user_pref("network.proxy.socks_port", 5);
  user_pref("network.proxy.ssl", "foo.bar");
  user_pref("network.proxy.ssl_port", 5);
  user_pref("network.proxy.type", 1);
  </code></pre>