-
-
Save dwinter/167740 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* I updated to Ubiquity 0.5 but found that broke | |
* Julien Couvreur's set-proxy command: | |
* http://blog.monstuff.com/archives/000342.html. | |
* So here is a re-write for the new parser. | |
*/ | |
CmdUtils.CreateCommand({ | |
names: ["set proxy", "proxy", "setproxy"], | |
description: "Switch you proxy without going through the preferences menu", | |
help: "Just type 'set proxy' then one of 'manual', 'off' 'pac', 'auto' or 'system'", | |
author: {name: "David Winter", email: "[email protected]"}, | |
license: "Go crazy...", | |
homepage: "http://gist.github.com/gists/167740/", | |
arguments: [{role: "object", | |
nountype: ["off", "manual", "pac", "auto", "system"], | |
label: "proxy setting"}], | |
preview: function( pblock, arguments ) { | |
pblock.innerHTML = _("change proxy setting to: ") + arguments.object.text; | |
}, | |
execute: function( arguments ) { | |
var proxy_code = this._getProxyCode( arguments.object.text ); | |
Application.prefs.setValue("network.proxy.type", proxy_code); | |
var msg = _("proxy set to ") + arguments.object.text | |
displayMessage( msg ) | |
}, | |
_getProxyCode: function( proxy_state ) { | |
switch ( proxy_state ){ | |
case "off" : return 0; | |
case "manual" : return 1; | |
case "auto" : return 2; | |
case "pac" : return 4; | |
case "system" : return 5; | |
default : return null; | |
} | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment