『第
2 楼』:
重新改了下:
cls&@echo off&color 2f&cd /d %~dp0
:::设置My.Pac存放路径路径
Set My_PacPath=d:\my.pac
Set AdPort=PROXY 255.255.255.0:3421
echo.&echo 正在查找设并置代理端口…………
for /f %%a in ('tasklist ^|findstr /i "proxy.exe"') do Set Port=PROXY 127.0.0.1:8000&echo.&echo 当前代理端口:127.0.0.1:8000&goto :开始
for /f %%a in ('tasklist ^|findstr /i "polipo.exe"') do Set Port=PROXY 127.0.0.1:8118&echo.&echo 当前代理端口:127.0.0.1:8118&goto :开始
for /f %%a in ('tasklist ^|findstr /i "privoxy.exe"') do Set Port=PROXY 127.0.0.1:8118&echo.&echo 当前代理端口:127.0.0.1:8118&goto :开始
for /f %%a in ('tasklist ^|findstr /i "AdvTor.exe"') do Set Port=PROXY 127.0.0.1:9050&echo.&echo 当前代理端口:127.0.0.1:9050&goto :开始
for /f %%a in ('tasklist ^|findstr /i "Tor.exe"') do Set Port=SOCKS 127.0.0.1:9050&echo.&echo 当前代理端口:SOCKS 127.0.0.1:9050&goto :开始
Set Port=DIRECT
echo.&echo 没有找到你的代理端口!请先运行代理软件或自行修改my.pac文件里的代理端口。&pause
:开始
echo.&echo 正在下载(AutoProxy gfwList)文件…………
echo ==============================================================================
Set My_Path=gfwlist.txt&Set My_Proxy=http://autoproxy-gfwlist.googlecode.com/svn/trunk/gfwlist.txt
If Exist "curl.exe" curl.exe "%My_Proxy%">%My_Path%_tmp.txt
If not Exist "curl.exe" Call :NewDete "%My_Proxy%" %My_Path%_tmp.txt
If not Exist "%My_Path%_tmp.txt" echo.&echo 没有下载完成………… &pause
If Exist "%My_Path%_tmp.txt" echo.&echo 下载完成………… &Call :Base64&Base64.exe -d %My_Path%_tmp.txt %My_Path%&del Base64.exe >nul
If Exist "My_Proxy.txt" (for /f "skip=1 delims=" %%a in (My_Proxy.txt) do echo %%a>>%My_Path%)
echo ==============================================================================
for %%a in (! [ ^( baidu) do Call :去掉包含指定字符串的行 %%a %My_Path%
for %%a in (a b) do Call :替换字符串 %%a %My_Path%
echo.&echo 正在去掉行头、尾特殊符号………… &Call :去掉行头尾特殊符号 %My_Path%
echo.&echo 正在删除重复行…………&Call :删除重复行 %My_Path%
for %%a in (mp mail www cn https://www.google.com https://chrome.google.com) do Call :去掉完全匹配的行 %%a %My_Path%
echo.&echo 正在写入代理脚本(%My_PacPath%)文件…………
>%My_PacPath% Echo function FindProxyForURL(url, host){
>>%My_PacPath% Echo var ProxyPort="%Port%";//根据你的代理软件修改代理地址和端口,将引号内的内容改为你的代理软件的ip:端口
>>%My_PacPath% Echo var Blackhole="%AdPort%";
>>%My_PacPath% Echo if (typeof(navigator) != 'undefined'
>>%My_PacPath% Echo ^&^& navigator.appVersion.indexOf("Mac") != -1) {
>>%My_PacPath% Echo Blackhole = "PROXY 0.0.0.0:3421";}
>>%My_PacPath% Echo if(/[/]([^^/]*?)(advert^|adverts?^|adimage^|adinfo^|adframe^|adserver^|admentor^|adview^|banner^|bannerimg^|popup^|popunder^|alimama^|popad^|special)(s)?[_.\/]/i.test(url)) return Blackhole;
>>%My_PacPath% Echo var adblocklist = new Array(
>>%My_PacPath% Echo ".ad.",
>>%My_PacPath% Echo "/ad.",
>>%My_PacPath% Echo ".ad-",
>>%My_PacPath% Echo ".ad?.",
>>%My_PacPath% Echo "/ad?.",
>>%My_PacPath% Echo "/ad/",
>>%My_PacPath% Echo "/ads/",
>>%My_PacPath% Echo "/gg/",
>>%My_PacPath% Echo "/gg.",
>>%My_PacPath% Echo "/gg?.",
>>%My_PacPath% Echo ".gg?.",
>>%My_PacPath% Echo ".gg.",
>>%My_PacPath% Echo "/cpro/",
If Exist "My_AdBlock.txt" (for /f "skip=1 delims=" %%a in (My_AdBlock.txt) do echo "%%a",>>%My_PacPath%)
>>%My_PacPath% Echo "_ad_");
>>%My_PacPath% Echo var patterns = new Array(
for /f %%i in (%My_Path%) do echo "%%i",>>%My_PacPath%
>>%My_PacPath% Echo "a.cc");
>>%My_PacPath% Echo for (i in adblocklist) {
>>%My_PacPath% Echo if(shExpMatch(url.toLowerCase(),"*" + adblocklist[i].toLowerCase() + "*")){return Blackhole;};
>>%My_PacPath% Echo };
>>%My_PacPath% Echo for (i in patterns) {
>>%My_PacPath% Echo if(shExpMatch(url.toLowerCase(),"*" + patterns[i].toLowerCase() + "*")){return ProxyPort;};
>>%My_PacPath% Echo };
>>%My_PacPath% Echo return "DIRECT";
>>%My_PacPath% Echo };
del %My_Path% >nul&echo.&&echo [ %My_PacPath% ]代理脚创建本完成,请按任意键退出!&&pause>nul&exit
:去掉完全匹配的行
echo.&echo 正在删除完全匹配 %1 的行…………
type %2|findstr /b /e /v "%1" >%2_tmp.txt
move %2_tmp.txt %2>nul
goto :eof
:去掉包含指定字符串的行
echo.&echo 正在删除包含 %1 字符串的行(不用代理的站点)…………
TYPE %2|findstr /I /V "%1">%2_tmp.txt
move %2_tmp.txt %2>nul
goto :eof
:替换字符串
setlocal enabledelayedexpansion
set replaced=%1
if /i "%1"=="a" set replaced=^|
if /i "%1"=="b" set replaced=^@
set all=
echo.&echo 正在替换 ^%replaced% 字符串…………
for /f "delims=" %%i in ('type "%2"') do (
set str=%%i
set "str=!str:%replaced%=%all%!"
echo !str!>>%2_tmp.txt
)
move "%2_tmp.txt" "%2" >nul
goto :eof
:删除重复行
sort %1>%1_tmp.txt
echo.>%1
for /f "delims=" %%i in (%1_tmp.txt) do (if not defined %%i set %%i=A & echo %%i>>%1)
del %1_tmp.txt >nul
goto :eof
:去掉行头尾特殊符号
setlocal enabledelayedexpansion
for /f %%i in ('type "%1"') do (
SET str=%%i
if "!str:~0,1!"=="*" set "str=!str:~1!"
if "!str:~0,1!"=="." set "str=!str:~1!"
if "!str:~0,1!"=="/" set "str=!str:~1!"
if "!str:~-1!"=="*" set "str=!str:~0,-1!"
if "!str:~-1!"=="/" set "str=!str:~0,-1!"
echo !str!>>%1_tmp.txt
)
move %1_tmp.txt "%1" >nul
goto :eof
:NewDete
>"get.vbs" echo Set x= createObject("Microsoft.XML" ^& wsq ^& "HTTP"):x.Open "GET",LCase(WScript.Arguments(0)),0:x.Send():Set s = createObject("ADODB.Stream"):s.Mode = 3:s.Type = 1:s.Open():s.Write(x.responseBody):s.SaveToFile LCase(WScript.Arguments(1)),2
cscript.exe //nologo "get.vbs" %1 %2&del "get.vbs">nul
goto :eof
:Base64
goto :eof [ Last edited by weasel on 2010-4-19 at 14:30 ]
附件
1: 瓦斯曲_代理脚本制作工具.rar (2010-4-19 14:27, 20.21 K,下载次数: 15)
|