-
-
Save bookfere/c9baf1d03d6f488c7033effbd541e628 to your computer and use it in GitHub Desktop.
:: Copyright (c)2022 https://bookfere.com | |
:: This is a batch script for fixing Google Translate and making it available | |
:: in the Chinese mainland. If you experience any problem, visit the page below: | |
:: https://bookfere.com/post/1020.html | |
@echo off | |
setlocal enabledelayedexpansion | |
chcp 437 >NUL | |
set "ips[0]=74.125.137.90" | |
set "ips[1]=74.125.193.186" | |
set "ips[2]=74.125.196.113" | |
set "ips[3]=108.177.97.100" | |
set "ips[4]=108.177.111.90" | |
set "ips[5]=108.177.122.90" | |
set "ips[6]=108.177.125.186" | |
set "ips[7]=108.177.126.90" | |
set "ips[8]=108.177.127.90" | |
set "ips[9]=142.250.0.90" | |
set "ips[10]=142.250.1.90" | |
set "ips[11]=142.250.4.90" | |
set "ips[12]=142.250.8.90" | |
set "ips[13]=142.250.9.90" | |
set "ips[14]=142.250.10.90" | |
set "ips[15]=142.250.11.90" | |
set "ips[16]=142.250.12.90" | |
set "ips[17]=142.250.13.90" | |
set "ips[18]=142.250.27.90" | |
set "ips[19]=142.250.28.90" | |
set "ips[20]=142.250.30.90" | |
set "ips[21]=142.250.31.90" | |
set "ips[22]=142.250.96.90" | |
set "ips[23]=142.250.97.90" | |
set "ips[24]=142.250.98.90" | |
set "ips[25]=142.250.99.90" | |
set "ips[26]=142.250.100.90" | |
set "ips[27]=142.250.101.90" | |
set "ips[28]=142.250.102.90" | |
set "ips[29]=142.250.103.90" | |
set "ips[30]=142.250.105.90" | |
set "ips[31]=142.250.107.90" | |
set "ips[32]=142.250.111.90" | |
set "ips[33]=142.250.112.90" | |
set "ips[34]=142.250.113.90" | |
set "ips[35]=142.250.114.90" | |
set "ips[36]=142.250.115.90" | |
set "ips[37]=142.250.123.90" | |
set "ips[38]=142.250.125.90" | |
set "ips[39]=142.250.126.90" | |
set "ips[40]=142.250.128.90" | |
set "ips[41]=142.250.138.90" | |
set "ips[42]=142.250.141.90" | |
set "ips[43]=142.250.142.90" | |
set "ips[44]=142.250.145.90" | |
set "ips[45]=142.250.152.90" | |
set "ips[46]=142.250.153.90" | |
set "ips[47]=142.250.157.90" | |
set "ips[48]=142.250.157.183" | |
set "ips[49]=142.250.157.184" | |
set "ips[50]=142.250.157.186" | |
set "ips[51]=142.250.158.90" | |
set "ips[52]=142.250.159.90" | |
set "ips[53]=142.251.1.90" | |
set "ips[54]=142.251.2.90" | |
set "ips[55]=142.251.4.90" | |
set "ips[56]=142.251.5.90" | |
set "ips[57]=142.251.6.90" | |
set "ips[58]=142.251.8.90" | |
set "ips[59]=142.251.9.90" | |
set "ips[60]=142.251.10.90" | |
set "ips[61]=142.251.12.90" | |
set "ips[62]=142.251.15.90" | |
set "ips[63]=142.251.16.90" | |
set "ips[64]=142.251.18.90" | |
set "ips[65]=142.251.107.90" | |
set "ips[66]=142.251.111.90" | |
set "ips[67]=142.251.112.90" | |
set "ips[68]=142.251.116.90" | |
set "ips[69]=142.251.117.90" | |
set "ips[70]=142.251.120.90" | |
set "ips[71]=142.251.160.90" | |
set "ips[72]=142.251.161.90" | |
set "ips[73]=142.251.162.90" | |
set "ips[74]=142.251.163.90" | |
set "ips[75]=142.251.166.90" | |
set "ips[76]=172.217.192.90" | |
set "ips[77]=172.217.195.90" | |
set "ips[78]=172.217.203.90" | |
set "ips[79]=172.217.204.90" | |
set "ips[80]=172.217.214.90" | |
set "ips[81]=172.217.215.90" | |
set "ips[82]=172.253.58.90" | |
set "ips[83]=172.253.62.90" | |
set "ips[84]=172.253.63.90" | |
set "ips[85]=172.253.112.90" | |
set "ips[86]=172.253.113.90" | |
set "ips[87]=172.253.114.90" | |
set "ips[88]=172.253.115.90" | |
set "ips[89]=172.253.116.90" | |
set "ips[90]=172.253.117.90" | |
set "ips[91]=172.253.118.90" | |
set "ips[92]=172.253.119.90" | |
set "ips[93]=172.253.123.90" | |
set "ips[94]=172.253.124.90" | |
set "ips[95]=172.253.125.90" | |
set "ips[96]=172.253.126.90" | |
set "ips[97]=172.253.127.90" | |
set "ips[98]=216.58.227.65" | |
set "ips[99]=216.58.227.66" | |
set "ips[100]=216.58.227.67" | |
set /a "index=%RANDOM% %% 101" | |
set "random_ip=!ips[%index%]!" | |
set "divider=----------------------------------------------" | |
set "target_domain=translate.googleapis.com" | |
set "hosts_file=C:\Windows\System32\drivers\etc\hosts" | |
goto :start | |
:generate_new_rule | |
echo Modify hosts file to fix Google translate service. | |
echo %divider% | |
echo [1] Automatically [2] Manually | |
echo %divider% | |
set /p action="Enter a number to choose an IP adding method:" | |
if "%action%"=="2" ( | |
set /p ip="Please enter a valid IP address: " | |
) | |
if "%ip%"=="" ( | |
set "ip=!random_ip!" | |
) | |
set "new_rule=%ip% %target_domain%" | |
goto:EOF | |
:start | |
set "old_rule=null" | |
set "comment=# Fix Google Translate CN" | |
for /f "tokens=*" %%i in ('type %hosts_file%') do ( | |
set "line=%%i" | |
:: Retrieve the rule If the target domain exists. | |
if not "!line:%target_domain%=!"=="%%i" set "old_rule=%%i" | |
) | |
if not "%old_rule%"=="null" ( | |
echo A rule has been added to the hosts file. | |
echo %divider% | |
echo [1] Update [2] Delete | |
echo %divider% | |
set /p action="Enter a number to choose an action: " | |
if "!action!"=="1" ( | |
call :generate_new_rule | |
if not "%old_rule%"=="!new_rule!" ( | |
echo Deleting the rule "%old_rule%" | |
echo Adding the rule "!new_rule!" | |
set "new_line=false" | |
for /f "tokens=*" %%i in ('type %hosts_file% ^| find /v /n "" ^& break ^> %hosts_file%') do ( | |
set "rule=%%i" | |
set "rule=!rule:*]=!" | |
if "%old_rule%"=="!rule!" set "rule=!new_rule!" | |
if "!new_line!"=="true" >>%hosts_file% echo. | |
>>%hosts_file% <NUL set /p="!rule!" | |
set "new_line=true" | |
) | |
) else ( | |
echo The rule already exists, nothing to do. | |
) | |
) else ( | |
if "!action!"=="2" ( | |
echo Deleting the rule "%old_rule%" | |
set "new_line=false" | |
for /f "tokens=*" %%i in (' | |
type "%hosts_file%" ^| findstr /v /c:"%comment%" ^| findstr /v "%target_domain%" ^| find /v /n "" ^& break ^> "%hosts_file%" | |
') do ( | |
set "line=%%i" | |
set "line=!line:*]=!" | |
if "!new_line!"=="true" >>%hosts_file% echo. | |
>>%hosts_file% <NUL set /p="!line!" | |
set "new_line=true" | |
) | |
) | |
) | |
) else ( | |
call :generate_new_rule | |
echo Adding the rule "!new_rule!" | |
echo.>>%hosts_file% | |
echo %comment%>>%hosts_file% | |
<NUL set /p="!new_rule!">>%hosts_file% | |
) | |
echo Done. | |
pause |
@bookfere 第 8 行
chcp 437 >NULL
这个 NULL 是不是应该是 NUL,不然每次运行后 CMD 的初始路径下都会跑出一个 NULL 的文件,里面存放了 chcp 命令的执行结果。。
谢谢指正!已修改。
142.250.0.90 translate.googleapis.com
Thank you very much, add this command or get good results.
脚本已支持手动输入 IP 地址。以下是一些可用 IP,可以尝试一下:
108.177.122.90
142.250.0.90
142.250.1.90
142.250.4.90
142.250.8.90
142.250.9.90
142.250.10.90
142.250.11.90
142.250.12.90
142.250.13.90
142.250.27.90
142.250.28.90
142.250.30.90
142.250.31.90
142.250.96.90
142.250.97.90
142.250.98.90
142.250.99.90
142.250.100.90
142.250.101.90
142.250.102.90
142.250.103.90
142.250.105.90
142.250.107.90
142.250.111.90
142.250.112.90
142.250.113.90
142.250.114.90
142.250.115.90
142.250.123.90
142.250.125.90
142.250.126.90
142.250.128.90
142.250.138.90
142.250.141.90
142.250.142.90
142.250.145.90
142.250.152.90
142.250.153.90
142.250.157.90
142.250.157.183
142.250.157.184
142.250.157.186
142.250.158.90
142.250.159.90
142.251.5.90
142.251.9.90
172.217.192.90
172.217.195.90
172.217.203.90
172.217.204.90
172.217.214.90
172.217.215.90
172.253.62.90
172.253.112.90
172.253.114.90
172.253.115.90
172.253.123.90
172.253.124.90
172.253.126.90
脚本已支持手动输入 IP 地址。以下是一些可用 IP,可以尝试一下:
108.177.122.90 142.250.0.90 142.250.1.90 142.250.4.90 142.250.8.90 142.250.9.90 142.250.10.90 142.250.11.90 142.250.12.90 142.250.13.90 142.250.27.90 142.250.28.90 142.250.30.90 142.250.31.90 142.250.96.90 142.250.97.90 142.250.98.90 142.250.99.90 142.250.100.90 142.250.101.90 142.250.102.90 142.250.103.90 142.250.105.90 142.250.107.90 142.250.111.90 142.250.112.90 142.250.113.90 142.250.114.90 142.250.115.90 142.250.123.90 142.250.125.90 142.250.126.90 142.250.128.90 142.250.138.90 142.250.141.90 142.250.142.90 142.250.145.90 142.250.152.90 142.250.153.90 142.250.157.90 142.250.157.183 142.250.157.184 142.250.157.186 142.250.158.90 142.250.159.90 142.251.5.90 142.251.9.90 172.217.192.90 172.217.195.90 172.217.203.90 172.217.204.90 172.217.214.90 172.217.215.90 172.253.62.90 172.253.112.90 172.253.114.90 172.253.115.90 172.253.123.90 172.253.124.90 172.253.126.90
Thank you very much.
2022.10.24 无法使用!
可以用Proxifier对全部的应用配置*.googleapis.com走代理。这样才能让chrome完全地代理掉翻译接口。
默认的各种代理的PAC等是不行的,这是不全局的其中一个方法。
原因是chrome会通过不寻常的请求方式然后免疫比较基础的代理方式。
再补充一些可用 IP 地址:
74.125.137.90
74.125.193.186
74.125.196.113
172.253.58.90
172.253.63.90
172.253.112.90
172.253.113.90
172.253.114.90
172.253.115.90
172.253.116.90
172.253.117.90
172.253.118.90
172.253.119.90
172.253.123.90
172.253.124.90
172.253.125.90
172.253.126.90
172.253.127.90
142.251.1.90
142.251.2.90
142.251.4.90
142.251.5.90
142.251.6.90
142.251.8.90
142.251.9.90
142.251.10.90
142.251.12.90
142.251.15.90
142.251.16.90
142.251.18.90
142.251.45.126
142.251.107.90
142.251.111.90
142.251.112.90
142.251.116.90
142.251.117.90
142.251.120.90
142.251.160.90
142.251.161.90
142.251.162.90
142.251.163.90
142.251.166.90
108.177.97.100
108.177.111.90
108.177.122.90
108.177.125.186
108.177.126.90
108.177.127.90
216.58.227.65
216.58.227.66
216.58.227.67
主播你视频中的二种方式都已经失效啊?请问有新文案吗?期待你的解说,我是你的老粉丝了!谢谢!
@zhuce1234 书伴没有发布过视频,只发布过这篇文章:https://bookfere.com/post/1020.html,目前文中介绍的两种方法仍然可用。
Thanks to the author's selfless dedication, it can be used normally again.
@bookfere 第 8 行
chcp 437 >NULL
这个 NULL 是不是应该是 NUL,不然每次运行后 CMD 的初始路径下都会跑出一个 NULL 的文件,里面存放了 chcp 命令的执行结果。。