firefox proxy settings via command line

后端 未结 19 1993
闹比i
闹比i 2020-12-02 18:20

How do I change Firefox Proxy settings via command line on windows xp/2k?

Thanks

19条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-02 19:02

    user.js is better for customizations as you can include only the lines you want to manipulate, i.e. instead of find-replace you can just overwrite the entire file. Also, prefs.js (at least on Firefox 65.0.1 for Mac) starts with a warning:

    // DO NOT EDIT THIS FILE.
    //
    // If you make changes to this file while the application is running,
    // the changes will be overwritten when the application exits.
    //
    // To change a preference value, you can either:
    // - modify it via the UI (e.g. via about:config in the browser); or
    // - set it within a user.js file in your profile.
    

    In my case, user.js didn't exist, so I created it and included the line to switch between "No proxy" and "Manual proxy configuration" (I'm using only one SOCKS proxy all the time, so no need to change port number or any other details, just flip 0 to 1 in the following line):

    user_pref("network.proxy.type", 1);

    I ended up with a bash script that I placed at /usr/local/bin/firefox:

    #!/bin/bash
    if [ $# -eq 0 ]; then
      echo 'user_pref("network.proxy.type", 0);' > ~/Library/Application\ Support/Firefox/Profiles/t5rvw47o.default/user.js
      open -a Firefox
    else
      case $1 in
        vpn)
          echo 'user_pref("network.proxy.type", 1);' > ~/Library/Application\ Support/Firefox/Profiles/t5rvw47o.default/user.js
          open -a Firefox
      esac 
    fi
    

    To use it, I make sure no Firefox is running and then run firefox to have a straight connection and firefox vpn to use proxy.

提交回复
热议问题