summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2012-03-08 07:38:36 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2012-03-08 07:38:36 +0100
commit6a6b7e91e38871cb4809115789edf9efe3343af0 (patch)
treeb977f9e17b01ae89c9847757cde3e7bd1d45ace6
downloadchromium-quick-proxy-6a6b7e91e38871cb4809115789edf9efe3343af0.tar.xz
chromium-quick-proxy-6a6b7e91e38871cb4809115789edf9efe3343af0.zip
Initial commit.
-rw-r--r--icon.pngbin0 -> 736 bytes
-rw-r--r--manifest.json12
-rw-r--r--popup.html79
3 files changed, 91 insertions, 0 deletions
diff --git a/icon.png b/icon.png
new file mode 100644
index 0000000..56ae280
--- /dev/null
+++ b/icon.png
Binary files differ
diff --git a/manifest.json b/manifest.json
new file mode 100644
index 0000000..2ccaaa8
--- /dev/null
+++ b/manifest.json
@@ -0,0 +1,12 @@
+{
+ "name": "Quick Proxy",
+ "version": "1.0",
+ "description": "Quick and dirty proxy switcher for Chromium.",
+ "browser_action": {
+ "default_icon": "icon.png",
+ "default_popup": "popup.html"
+ },
+ "permissions": [
+ "proxy"
+ ]
+} \ No newline at end of file
diff --git a/popup.html b/popup.html
new file mode 100644
index 0000000..9f56e00
--- /dev/null
+++ b/popup.html
@@ -0,0 +1,79 @@
+<html>
+<head>
+<style>
+body {
+ font-family: sans-serif;
+ margin: 0;
+ width: 200px;
+ height: 110px;
+}
+</style>
+<script>
+window.onload = function() {
+ chrome.proxy.settings.get({ incognito: false }, function(config) {
+ var inputs = document.getElementsByTagName("input");
+ var setPreset = false;
+ var parseUrl = function(url) {
+ return { scheme: url.substring(0, url.indexOf(":")), host: url.substring(url.lastIndexOf("/") + 1, url.lastIndexOf(":")), port: parseInt(url.substring(url.lastIndexOf(":") + 1)) };
+ };
+ var parseObject = function(obj) {
+ return obj.scheme + "://" + obj.host + ":" + obj.port;
+ };
+ for (var i = 0; i < inputs.length; ++i) {
+ if (inputs[i].value == "system") {
+ inputs[i].onclick = function() {
+ chrome.proxy.settings.set({ value: { mode: "system" }, scope: "regular" }, function() { window.close(); });
+ };
+ if (config.value.mode == "system")
+ inputs[i].checked = true;
+ } else if (inputs[i].value == "direct") {
+ inputs[i].onclick = function() {
+ chrome.proxy.settings.set({ value: { mode: "direct" }, scope: "regular" }, function() { window.close(); });
+ };
+ if (config.value.mode == "direct")
+ inputs[i].checked = true;
+ } else if (inputs[i].value == "other") {
+ var other = document.getElementById("other");
+ var setOther = function() {
+ chrome.proxy.settings.set({ value: { mode: "fixed_servers", rules:
+ { singleProxy: parseUrl(other.value) } },
+ scope: "regular" }, function() { window.close(); });
+ };
+ other.onblur = setOther;
+ var me = inputs[i];
+ window.onunload = function() {
+ if (me.checked)
+ setOther();
+ };
+ other.onkeypress = function() {
+ me.checked = true;
+ };
+ if (!setPreset && config.value.mode == "fixed_servers" && typeof config.value.rules.singleProxy != "undefined") {
+ other.value = parseObject(config.value.rules.singleProxy);
+ inputs[i].checked = true;
+ }
+ } else {
+ inputs[i].onclick = function() {
+ chrome.proxy.settings.set({ value: { mode: "fixed_servers", rules:
+ { singleProxy: parseUrl(this.value) } },
+ scope: "regular" }, function() { window.close(); });
+ };
+ if (config.value.mode == "fixed_servers" && typeof config.value.rules.singleProxy != "undefined" && inputs[i].value == parseObject(config.value.rules.singleProxy)) {
+ inputs[i].checked = true;
+ setPreset = true;
+ }
+ }
+ }
+ });
+};
+</script>
+</head>
+<body>
+<label><input type="radio" name="proxy" value="socks5://localhost:1080" />socks5://localhost:1080</label><br />
+<label><input type="radio" name="proxy" value="socks5://localhost:9050" />socks5://localhost:9050</label><br />
+<label><input type="radio" name="proxy" value="http://localhost:8080" />http://localhost:8080</label><br />
+<label><input type="radio" name="proxy" value="other" /><input id="other" /></label><br />
+<label><input type="radio" name="proxy" value="system" />system</label><br />
+<label><input type="radio" name="proxy" value="direct" />direct</label>
+</body>
+</html>