找回密码
 注册
搜索
免费空间 免费域名 免费AI 老牌主机商首月仅1美分!27美元/年!Spaceship优惠码 Namecheap优惠码阿里云2核2G3M新老续费同享99元/年!
查看: 324|回复: 0

[程序代码] 修复Google浏览器翻译

[复制链接]
发表于 2022-12-4 09:36:06 | 显示全部楼层 |阅读模式
复制以下代码保存为xxx.bat文件,右键管理员身份运行。两次命令输入“1”回车即可。
A rule has been added to the hosts file.
----------------------------------------------
[1] Update [2] Delete
----------------------------------------------
Enter a number to choose an action: 1
Modify hosts file to fix Google translate serv
----------------------------------------------
[1] Automatically [2] Manually
----------------------------------------------
Enter a number to choose an IP adding method:1

保存以下代码为xxx.bat
  1. :: Copyright (c)2022 https://bookfere.com
  2. :: This is a batch script for fixing Google Translate and making it available
  3. :: in the Chinese mainland. If you experience any problem, visit the page below:
  4. :: https://bookfere.com/post/1020.html

  5. @echo off
  6. setlocal enabledelayedexpansion
  7. chcp 437 >NUL

  8. set "ips[0]=74.125.137.90"
  9. set "ips[1]=74.125.193.186"
  10. set "ips[2]=74.125.196.113"
  11. set "ips[3]=108.177.97.100"
  12. set "ips[4]=108.177.111.90"
  13. set "ips[5]=108.177.122.90"
  14. set "ips[6]=108.177.125.186"
  15. set "ips[7]=108.177.126.90"
  16. set "ips[8]=108.177.127.90"
  17. set "ips[9]=142.250.0.90"
  18. set "ips[10]=142.250.1.90"
  19. set "ips[11]=142.250.4.90"
  20. set "ips[12]=142.250.8.90"
  21. set "ips[13]=142.250.9.90"
  22. set "ips[14]=142.250.10.90"
  23. set "ips[15]=142.250.11.90"
  24. set "ips[16]=142.250.12.90"
  25. set "ips[17]=142.250.13.90"
  26. set "ips[18]=142.250.27.90"
  27. set "ips[19]=142.250.28.90"
  28. set "ips[20]=142.250.30.90"
  29. set "ips[21]=142.250.31.90"
  30. set "ips[22]=142.250.96.90"
  31. set "ips[23]=142.250.97.90"
  32. set "ips[24]=142.250.98.90"
  33. set "ips[25]=142.250.99.90"
  34. set "ips[26]=142.250.100.90"
  35. set "ips[27]=142.250.101.90"
  36. set "ips[28]=142.250.102.90"
  37. set "ips[29]=142.250.103.90"
  38. set "ips[30]=142.250.105.90"
  39. set "ips[31]=142.250.107.90"
  40. set "ips[32]=142.250.111.90"
  41. set "ips[33]=142.250.112.90"
  42. set "ips[34]=142.250.113.90"
  43. set "ips[35]=142.250.114.90"
  44. set "ips[36]=142.250.115.90"
  45. set "ips[37]=142.250.123.90"
  46. set "ips[38]=142.250.125.90"
  47. set "ips[39]=142.250.126.90"
  48. set "ips[40]=142.250.128.90"
  49. set "ips[41]=142.250.138.90"
  50. set "ips[42]=142.250.141.90"
  51. set "ips[43]=142.250.142.90"
  52. set "ips[44]=142.250.145.90"
  53. set "ips[45]=142.250.152.90"
  54. set "ips[46]=142.250.153.90"
  55. set "ips[47]=142.250.157.90"
  56. set "ips[48]=142.250.157.183"
  57. set "ips[49]=142.250.157.184"
  58. set "ips[50]=142.250.157.186"
  59. set "ips[51]=142.250.158.90"
  60. set "ips[52]=142.250.159.90"
  61. set "ips[53]=142.251.1.90"
  62. set "ips[54]=142.251.2.90"
  63. set "ips[55]=142.251.4.90"
  64. set "ips[56]=142.251.5.90"
  65. set "ips[57]=142.251.6.90"
  66. set "ips[58]=142.251.8.90"
  67. set "ips[59]=142.251.9.90"
  68. set "ips[60]=142.251.10.90"
  69. set "ips[61]=142.251.12.90"
  70. set "ips[62]=142.251.15.90"
  71. set "ips[63]=142.251.16.90"
  72. set "ips[64]=142.251.18.90"
  73. set "ips[65]=142.251.107.90"
  74. set "ips[66]=142.251.111.90"
  75. set "ips[67]=142.251.112.90"
  76. set "ips[68]=142.251.116.90"
  77. set "ips[69]=142.251.117.90"
  78. set "ips[70]=142.251.120.90"
  79. set "ips[71]=142.251.160.90"
  80. set "ips[72]=142.251.161.90"
  81. set "ips[73]=142.251.162.90"
  82. set "ips[74]=142.251.163.90"
  83. set "ips[75]=142.251.166.90"
  84. set "ips[76]=172.217.192.90"
  85. set "ips[77]=172.217.195.90"
  86. set "ips[78]=172.217.203.90"
  87. set "ips[79]=172.217.204.90"
  88. set "ips[80]=172.217.214.90"
  89. set "ips[81]=172.217.215.90"
  90. set "ips[82]=172.253.58.90"
  91. set "ips[83]=172.253.62.90"
  92. set "ips[84]=172.253.63.90"
  93. set "ips[85]=172.253.112.90"
  94. set "ips[86]=172.253.113.90"
  95. set "ips[87]=172.253.114.90"
  96. set "ips[88]=172.253.115.90"
  97. set "ips[89]=172.253.116.90"
  98. set "ips[90]=172.253.117.90"
  99. set "ips[91]=172.253.118.90"
  100. set "ips[92]=172.253.119.90"
  101. set "ips[93]=172.253.123.90"
  102. set "ips[94]=172.253.124.90"
  103. set "ips[95]=172.253.125.90"
  104. set "ips[96]=172.253.126.90"
  105. set "ips[97]=172.253.127.90"
  106. set "ips[98]=216.58.227.65"
  107. set "ips[99]=216.58.227.66"
  108. set "ips[100]=216.58.227.67"

  109. set /a "index=%RANDOM% %% 101"
  110. set "random_ip=!ips[%index%]!"

  111. set "divider=----------------------------------------------"
  112. set "target_domain=translate.googleapis.com"
  113. set "hosts_file=C:\Windows\System32\drivers\etc\hosts"

  114. goto :start

  115. :generate_new_rule
  116.     echo Modify hosts file to fix Google translate service.
  117.     echo %divider%
  118.     echo [1] Automatically [2] Manually
  119.     echo %divider%
  120.     set /p action="Enter a number to choose an IP adding method:"

  121.     if "%action%"=="2" (
  122.         set /p ip="Please enter a valid IP address: "
  123.     )

  124.     if "%ip%"=="" (
  125.         set "ip=!random_ip!"
  126.     )

  127.     set "new_rule=%ip% %target_domain%"
  128. goto:EOF

  129. :start

  130. set "old_rule=null"
  131. set "comment=# Fix Google Translate CN"

  132. for /f "tokens=*" %%i in ('type %hosts_file%') do (
  133.     set "line=%%i"
  134.     :: Retrieve the rule If the target domain exists.
  135.     if not "!line:%target_domain%=!"=="%%i" set "old_rule=%%i"
  136. )

  137. if not "%old_rule%"=="null" (
  138.     echo A rule has been added to the hosts file.
  139.     echo %divider%
  140.     echo [1] Update [2] Delete
  141.     echo %divider%
  142.     set /p action="Enter a number to choose an action: "
  143.     if "!action!"=="1" (
  144.         call :generate_new_rule
  145.         if not "%old_rule%"=="!new_rule!" (
  146.             echo Deleting the rule "%old_rule%"
  147.             echo Adding the rule "!new_rule!"
  148.             set "new_line=false"
  149.             for /f "tokens=*" %%i in ('type %hosts_file% ^| find /v /n "" ^& break ^> %hosts_file%') do (
  150.                 set "rule=%%i"
  151.                 set "rule=!rule:*]=!"
  152.                 if "%old_rule%"=="!rule!" set "rule=!new_rule!"
  153.                 if "!new_line!"=="true" >>%hosts_file% echo.
  154.                 >>%hosts_file% <NUL set /p="!rule!"
  155.                 set "new_line=true"
  156.             )
  157.         ) else (
  158.             echo The rule already exists, nothing to do.
  159.         )
  160.     ) else (
  161.         if "!action!"=="2" (
  162.             echo Deleting the rule "%old_rule%"
  163.             set "new_line=false"
  164.             for /f "tokens=*" %%i in ('
  165.                 type "%hosts_file%" ^| findstr /v /c:"%comment%" ^| findstr /v "%target_domain%" ^| find /v /n "" ^& break ^> "%hosts_file%"
  166.             ') do (
  167.                 set "line=%%i"
  168.                 set "line=!line:*]=!"
  169.                 if "!new_line!"=="true" >>%hosts_file% echo.
  170.                 >>%hosts_file% <NUL set /p="!line!"
  171.                 set "new_line=true"
  172.             )
  173.         )
  174.     )
  175. ) else (
  176.     call :generate_new_rule
  177.     echo Adding the rule "!new_rule!"
  178.     echo.>>%hosts_file%
  179.     echo %comment%>>%hosts_file%
  180.     <NUL set /p="!new_rule!">>%hosts_file%
  181. )

  182. echo Done.
  183. pause
复制代码

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|免费吧论坛

GMT+8, 2024-12-23 15:56 , Processed in 0.028528 second(s), 3 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表