├── .gitignore ├── IAutoProxy.idl ├── Packager.pm ├── README ├── apdiff.sh ├── chrome.manifest ├── chrome ├── content │ ├── errors.html │ ├── filterClasses.js │ ├── filterListener.js │ ├── filterStorage.js │ ├── matcher.js │ ├── policy.js │ ├── prefs.js │ ├── proxy.js │ ├── requests.js │ ├── subscriptionClasses.js │ ├── synchronizer.js │ ├── ui │ │ ├── about.js │ │ ├── about.xul │ │ ├── browserWindow.js │ │ ├── chooseProxyServer.js │ │ ├── chooseProxyServer.xul │ │ ├── editProxyServer.js │ │ ├── editProxyServer.xul │ │ ├── enableProxyOn.js │ │ ├── findbar.js │ │ ├── firefoxOverlay.xul │ │ ├── flasher.js │ │ ├── mailOverlay.xul │ │ ├── optionsOverlay.js │ │ ├── optionsOverlay.xul │ │ ├── overlay.js │ │ ├── overlayGeneral.xul │ │ ├── prismOverlay.xul │ │ ├── seamonkeyOverlay.xul │ │ ├── settings.js │ │ ├── settings.xul │ │ ├── sidebar.js │ │ ├── sidebar.xul │ │ ├── sidebarDetached.xul │ │ ├── subscription.js │ │ ├── subscription.xul │ │ ├── subscriptions.xml │ │ ├── tip_subscriptions.js │ │ ├── tip_subscriptions.xul │ │ └── utils.js │ └── utils.js ├── locale │ ├── de │ │ ├── about.dtd │ │ ├── chooseProxyServer.dtd │ │ ├── editProxyServer.dtd │ │ ├── global.properties │ │ ├── overlay.dtd │ │ ├── settings.dtd │ │ ├── sidebar.dtd │ │ ├── subscription.dtd │ │ └── tip_subscriptions.dtd │ ├── en-US │ │ ├── about.dtd │ │ ├── chooseProxyServer.dtd │ │ ├── editProxyServer.dtd │ │ ├── global.properties │ │ ├── overlay.dtd │ │ ├── settings.dtd │ │ ├── sidebar.dtd │ │ ├── subscription.dtd │ │ └── tip_subscriptions.dtd │ ├── es-ES │ │ ├── about.dtd │ │ ├── chooseProxyServer.dtd │ │ ├── editProxyServer.dtd │ │ ├── global.properties │ │ ├── overlay.dtd │ │ ├── settings.dtd │ │ ├── sidebar.dtd │ │ ├── subscription.dtd │ │ └── tip_subscriptions.dtd │ ├── fr │ │ ├── about.dtd │ │ ├── chooseProxyServer.dtd │ │ ├── editProxyServer.dtd │ │ ├── global.properties │ │ ├── overlay.dtd │ │ ├── settings.dtd │ │ ├── sidebar.dtd │ │ ├── subscription.dtd │ │ └── tip_subscriptions.dtd │ ├── pt-BR │ │ ├── about.dtd │ │ ├── chooseProxyServer.dtd │ │ ├── editProxyServer.dtd │ │ ├── global.properties │ │ ├── overlay.dtd │ │ ├── settings.dtd │ │ ├── sidebar.dtd │ │ ├── subscription.dtd │ │ └── tip_subscriptions.dtd │ ├── sq-AL │ │ ├── about.dtd │ │ ├── chooseProxyServer.dtd │ │ ├── editProxyServer.dtd │ │ ├── global.properties │ │ ├── overlay.dtd │ │ ├── settings.dtd │ │ ├── sidebar.dtd │ │ ├── subscription.dtd │ │ └── tip_subscriptions.dtd │ ├── sv-SE │ │ ├── about.dtd │ │ ├── chooseProxyServer.dtd │ │ ├── editProxyServer.dtd │ │ ├── global.properties │ │ ├── overlay.dtd │ │ ├── settings.dtd │ │ ├── sidebar.dtd │ │ ├── subscription.dtd │ │ └── tip_subscriptions.dtd │ └── zh-CN │ │ ├── about.dtd │ │ ├── chooseProxyServer.dtd │ │ ├── editProxyServer.dtd │ │ ├── global.properties │ │ ├── overlay.dtd │ │ ├── settings.dtd │ │ ├── sidebar.dtd │ │ ├── subscription.dtd │ │ └── tip_subscriptions.dtd └── skin │ ├── about.css │ ├── aup-status-16.png │ ├── aup-status.png │ ├── checkbox.png │ ├── chooseProxyServer.css │ ├── close.png │ ├── editProxyServer.css │ ├── item-state.png │ ├── overlay.css │ ├── seaMonkeyHack.css │ ├── settings.css │ ├── sidebar.css │ ├── subscription.css │ └── tip_subscriptions.css ├── components └── AutoProxy.js ├── create_xpi.pl ├── defaults └── preferences │ └── autoproxy.js ├── icon.png ├── install.rdf ├── make_babelzilla_build.pl ├── make_devbuild.pl ├── make_devbuild.sh ├── make_release.pl ├── remove_string.pl ├── search_and_replace.pl ├── setupTestEnvironment.pl ├── test_locales.pl └── update.rdf /.gitignore: -------------------------------------------------------------------------------- 1 | *.xpi 2 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | AutoProxy - the firefox proxy management add-on 2 | 3 | What's New 4 | === 5 | Version 0.2.0 released at 08, Mar, 2009. 6 | After ability of subscribe to pattern lists, we now can custom the proxy server. 7 | 8 | More details see below. 9 | 10 | 11 | Introduction 12 | === 13 | AutoProxy == 14 | 15 | Better FoxyProxy (Use patterns to determine which or none proxy server to be 16 | used when connecting, no need to switch proxy status manually any more.) + 17 | 18 | * Better UI -- I think so (AutoProxy is derived from Adblock Plus, 19 | if you like the interface of ABP, you may also like AutoProxy.) 20 | 21 | * More efficient -- the truth (matching algorithm has a constant time complexity, 22 | the time used for matching is almost independent from the number of patterns) 23 | 24 | 25 | Subscribe (Like Adblock Plus. Advanced users can share their patterns to the 26 | whole world/country/school..., while normal users even don't need to know 27 | what a pattern is, just subscribe to a maintained pattern list. Even if people 28 | know well about this, why should we waste our time to write so many duplicate 29 | patterns again and again?) + 30 | 31 | 32 | Built-in Proxy Server (You also don't trouble to find and run a proxy server, 33 | here is a built-in one. Immediately work after install, no configuration 34 | needed -- Of course, you can turn it off and use other proxies.) 35 | 36 | 37 | 38 | 39 | Where and How to Install 40 | === 41 | Install is very easy, just a click. Like other normal Firefox extensions. 42 | 43 | Please move there: http://fxthunder.com/files/autoproxy.xpi 44 | 45 | 46 | 47 | 48 | Status 49 | === 50 | AutoProxy already works well. Include: 51 | 52 | * Write your own patterns; 53 | * Subscribe to pattern lists; 54 | * Custom proxy servers; 55 | * ...... 56 | 57 | But some of it's features are still under development. Include: 58 | 59 | * Built-in server; 60 | * Multi Proxies support; 61 | * ...... 62 | 63 | 64 | Chen Ergan 65 | -------------------------------------------------------------------------------- /apdiff.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Since we replaced all 'abp' string with 'aup', 4 | # it causes problems when we diff these two repositories. 5 | # 6 | # This script is used to handle such problem. 7 | # 8 | # @usage: same as `diff` 9 | # @example: $./apdiff.sh -rBb chrome/content/ ../adblockplus/chrome/content/ 10 | # @output: same as `diff` but will ignore lines which diff only because abp/aup 11 | ################################################################################ 12 | 13 | diff $* > temp.diff; 14 | 15 | curLineNum=1; 16 | while true 17 | do 18 | curLine=$(sed -n "$curLineNum{p;q;}" temp.diff); 19 | if [[ "$curLine" =~ ^\< ]]; then 20 | FoundNextDiff=false; 21 | ((nextDiffNum = $curLineNum + 1)); 22 | 23 | while true 24 | do 25 | nextDiff=$(sed -n "$nextDiffNum{p;q;}" temp.diff); 26 | if [[ "$nextDiff" =~ ^\> ]]; then 27 | FoundNextDiff=true; 28 | nextDiff=${nextDiff/#>/<}; 29 | nextDiff=${nextDiff//abp/aup}; 30 | nextDiff=${nextDiff//ABP/AUP}; 31 | nextDiff=${nextDiff//adblockplus/autoproxy}; 32 | nextDiff=${nextDiff//AdblockPlus/AutoProxy}; 33 | nextDiff=${nextDiff//Adblock Plus/AutoProxy}; 34 | nextDiff=${nextDiff//Adblock/AutoProxy}; 35 | nextDiff=${nextDiff//adblock/AutoProxy}; 36 | if [ "$nextDiff" == "$curLine" ]; then 37 | sed -i "$nextDiffNum d" temp.diff; 38 | sed -i "$curLineNum d" temp.diff; 39 | ((curLineNum--)); 40 | break; 41 | fi 42 | elif $FoundNextDiff; then 43 | break; 44 | elif [ "$nextDiff" == "" ]; then 45 | break; 46 | fi 47 | ((nextDiffNum++)); 48 | done 49 | 50 | elif [ "$curLine" == "" ]; then # EOF 51 | break; 52 | fi 53 | 54 | ((curLineNum++)); 55 | done 56 | 57 | 58 | # remove lines like this: 59 | # "191c191" followed by "---" 60 | # 61 | # Note: 62 | # `sed` access the newest temp.diff from disk every time, 63 | # 'while read' uses old unmodified temp.diff forever, they are independent. 64 | # 65 | curLineNum=1; 66 | while read curLine 67 | do 68 | if [[ "$curLine" =~ ^[1-9] ]]; then 69 | ((nextLineNum = $curLineNum + 1)); 70 | nextLine=$(sed -n "$nextLineNum{p;q;}" temp.diff); 71 | if [[ "$nextLine" =~ ^---$ ]]; then 72 | sed -i "$nextLineNum d" temp.diff; 73 | sed -i "$curLineNum d" temp.diff; 74 | ((curLineNum -= 2)); 75 | fi 76 | fi 77 | ((curLineNum++)); 78 | done < temp.diff 79 | 80 | # highlight in vim looks better than `echo` 81 | vim temp.diff; 82 | -------------------------------------------------------------------------------- /chrome.manifest: -------------------------------------------------------------------------------- 1 | content autoproxy chrome/content/ 2 | 3 | overlay chrome://browser/content/browser.xul chrome://autoproxy/content/ui/firefoxOverlay.xul 4 | overlay chrome://navigator/content/navigator.xul chrome://autoproxy/content/ui/seamonkeyOverlay.xul 5 | overlay chrome://messenger/content/mailWindowOverlay.xul chrome://autoproxy/content/ui/mailOverlay.xul 6 | overlay chrome://midbrowser/content/midbrowser.xul chrome://autoproxy/content/ui/firefoxOverlay.xul 7 | overlay chrome://emusic/content/startup.xul chrome://autoproxy/content/ui/firefoxOverlay.xul 8 | overlay chrome://webrunner/content/webrunner.xul chrome://autoproxy/content/ui/prismOverlay.xul 9 | overlay chrome://browser/content/preferences/preferences.xul chrome://autoproxy/content/ui/optionsOverlay.xul 10 | 11 | skin autoproxy classic/1.0 chrome/skin/ 12 | style chrome://global/content/customizeToolbar.xul chrome://autoproxy/skin/overlay.css 13 | style chrome://autoproxy/content/ui/seamonkeyOverlay.xul chrome://autoproxy/skin/seaMonkeyHack.css application={92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a} 14 | style chrome://autoproxy/content/ui/mailOverlay.xul chrome://autoproxy/skin/seaMonkeyHack.css application={92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a} 15 | 16 | locale autoproxy de chrome/locale/de/ 17 | locale autoproxy en-US chrome/locale/en-US/ 18 | locale autoproxy es-ES chrome/locale/es-ES/ 19 | locale autoproxy fr chrome/locale/fr/ 20 | locale autoproxy pt-BR chrome/locale/pt-BR/ 21 | locale autoproxy sq-AL chrome/locale/sq-AL/ 22 | locale autoproxy sv-SE chrome/locale/sv-SE/ 23 | locale autoproxy zh-CN chrome/locale/zh-CN/ 24 | 25 | component {6b6b24d0-63c3-11de-8a39-0800200c9a66} components/AutoProxy.js 26 | contract @autoproxy.org/aup/startup;1 {6b6b24d0-63c3-11de-8a39-0800200c9a66} 27 | category profile-after-change @autoproxy.org/aup/startup;1 @autoproxy.org/aup/startup;1 28 | 29 | component {7FCE727A-028D-11DE-9E0F-298E56D89593} components/AutoProxy.js 30 | contract @mozilla.org/autoproxy;1 {7FCE727A-028D-11DE-9E0F-298E56D89593} 31 | category content-policy AUPComponent @mozilla.org/autoproxy;1 32 | category net-channel-event-sinks AUPComponent @mozilla.org/autoproxy;1 33 | 34 | # Hack to prevent .Net Framework Assistant from messing up the browser 35 | override chrome://dotnetassistant/content/bootstrap.xul data:text/xml, 36 | 37 | # Hack to make icon.png available as autoproxy.png in the skin 38 | skin autoproxy_icon classic/1.0 ./ 39 | override chrome://autoproxy/skin/autoproxy.png chrome://autoproxy_icon/skin/icon.png 40 | -------------------------------------------------------------------------------- /chrome/content/errors.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | AutoProxy Errors 4 | 27 | 28 | 29 | 30 | 31 | 32 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /chrome/content/proxy.js: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is AutoProxy. 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Wang Congming . 18 | * Portions created by the Initial Developer are Copyright (C) 2010-2011 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * 2010: slimx . 23 | * 24 | * ***** END LICENSE BLOCK ***** */ 25 | 26 | /** 27 | * Core implementation of proxy mechanism 28 | * This file is included from AutoProxy.js. 29 | */ 30 | 31 | const pS = Cc['@mozilla.org/network/protocol-proxy-service;1'].getService(Ci.nsIProtocolProxyService); 32 | 33 | var proxy = 34 | { 35 | server: null, 36 | getName: null, 37 | defaultProxy: null, 38 | validConfigs: null, 39 | mode: ['auto', 'global', 'disabled'], 40 | direct: pS.newProxyInfo('direct', '', -1, 0, 0, null), 41 | 42 | init: function() 43 | { 44 | this.reloadPrefs(); 45 | prefs.addListener(this.reloadPrefs); 46 | }, 47 | 48 | reloadPrefs: function() 49 | { 50 | // Refresh validConfigs - array of objects 51 | proxy.validConfigs = proxy.configToObj(prefs.customProxy) || 52 | proxy.configToObj(prefs.knownProxy); 53 | 54 | /** 55 | * Refresh proxy name & available proxy servers 56 | * 57 | * newProxyInfo(type, host, port, socks_remote_dns, failoverTimeout, failoverProxy) 58 | */ 59 | proxy.server = []; proxy.getName = []; 60 | for each (var conf in proxy.validConfigs) { 61 | proxy.getName.push(conf.name); 62 | proxy.server.push(pS.newProxyInfo(conf.type, conf.host, conf.port, 1, 0, null)); 63 | } 64 | 65 | // Refresh defaultProxy {nsIProxyInfo} 66 | proxy.defaultProxy = proxy.server[prefs.defaultProxy] || proxy.server[0]; 67 | proxy.nameOfDefaultProxy = proxy.getName[prefs.defaultProxy] || proxy.getName[0]; 68 | 69 | // Refresh fallbackProxy {nsIProxyInfo} 70 | proxy.fallbackProxy = prefs.fallbackProxy == -1 ? 71 | proxy.direct : proxy.server[prefs.fallbackProxy]; 72 | 73 | pS.unregisterFilter(proxy); 74 | pS.registerFilter(proxy, 0); 75 | }, 76 | 77 | /** 78 | * Convert proxy config(e.g.: prefs.knownProxy) to objects for convenient usage later 79 | * 80 | * @param config {String} 81 | * @return {Array} of objects 82 | */ 83 | configToObj: function(config) 84 | { 85 | var proxyObjArray = []; 86 | 87 | for each (var proxyAttr in config.split('$')) { 88 | proxyAttr = proxyAttr.split(';'); 89 | if (proxyAttr.length != 4 || proxyAttr[0] == '' || isNaN(proxyAttr[2])) 90 | continue; 91 | 92 | var proxyObj = {}; 93 | proxyObj.name = proxyAttr[0]; 94 | proxyObj.host = proxyAttr[1] == '' ? '127.0.0.1' : proxyAttr[1]; 95 | proxyObj.port = proxyAttr[2]; 96 | proxyObj.type = /^socks4?$/i.test(proxyAttr[3]) ? proxyAttr[3] : 'http'; 97 | proxyObjArray.push(proxyObj); 98 | } 99 | 100 | return proxyObjArray.length == 0 ? false : proxyObjArray; 101 | }, 102 | 103 | /** 104 | * Checks whether the location's scheme is proxyable 105 | * 106 | * @param location {nsIURI} 107 | * @return {Boolean} 108 | */ 109 | isProxyableScheme: function(location) 110 | { 111 | return ['http', 'https', 'ftp', 'gopher'].some( 112 | function(scheme){return location.scheme==scheme;}); 113 | }, 114 | 115 | /** 116 | * Switch to specified proxy mode 117 | * @param mode {String} see this.mode 118 | */ 119 | switchToMode: function(mode) 120 | { 121 | prefs.proxyMode = mode; 122 | prefs.save(); 123 | }, 124 | 125 | // 126 | // nsIProtocolProxyFilter implementation 127 | // 128 | applyFilter: function(pS, uri, aProxy) 129 | { 130 | if (prefs.proxyMode == 'disabled' || uri.schemeIs('feed')) 131 | return this.direct; 132 | 133 | var match = policy.autoMatching(uri); 134 | 135 | if (this.isNoProxy(match)) return this.direct; 136 | if (prefs.proxyMode == "auto") 137 | return this.getGroupProxy(match) || this.fallbackProxy; 138 | 139 | return this.defaultProxy; 140 | }, 141 | 142 | // @todo: bug, whitelist in other group may overwrite "global no proxy" group 143 | isNoProxy: function(match) 144 | { 145 | if (match instanceof WhitelistFilter) 146 | // for each (var s in match.subscriptions) 147 | // if (!s.disabled && s.url == "~wl~") 148 | return true; 149 | 150 | return false; 151 | }, 152 | 153 | getGroupProxy: function(match) 154 | { 155 | if (!match || match instanceof WhitelistFilter) return null; 156 | for each (var s in match.subscriptions) 157 | if (!s.disabled) 158 | return this.server[s.proxy] || this.defaultProxy; 159 | } 160 | }; 161 | 162 | aup.proxy = proxy; 163 | 164 | // @TODO: ";" & "$" is not allowed in proxy name 165 | // @TODO: review editProxyServer.js 166 | // @TODO: proxy name should be unique 167 | // @TODO: aup.getString('no proxy') && aup.getString('default proxy') are reserved 168 | -------------------------------------------------------------------------------- /chrome/content/ui/about.js: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is Adblock Plus. 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Wladimir Palant. 18 | * Portions created by the Initial Developer are Copyright (C) 2006-2009 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * 23 | * ***** END LICENSE BLOCK ***** */ 24 | 25 | var versionField = document.getElementById("version"), 26 | sloganField = document.getElementById("slogan"); 27 | 28 | versionField.value = aup.getInstalledVersion(); 29 | sloganField.value = aup.getString("extensions.autoproxy@autoproxy.org.description"); 30 | 31 | // Work-around for bug 494901, change align attribute to ensure correct positioning 32 | versionField.parentNode.setAttribute("align", "baseline"); 33 | -------------------------------------------------------------------------------- /chrome/content/ui/about.xul: -------------------------------------------------------------------------------- 1 | 2 | 3 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 45 | 46 | 47 | 48 | 49 | 52 | 53 | 54 | 57 | 58 | 59 | 60 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 |