首页 > 其他分享 >google网页翻译无法使用

google网页翻译无法使用

时间:2022-11-15 11:56:49浏览次数:55  
标签:翻译 google 网页 %% rule echo set hosts rule%

复制以下脚本到本地txt文件中,更改后缀为.bat 以管理员身份执行bat脚本即可

@setlocal enabledelayedexpansion
@echo off
set "source_domain=google.cn"
set "target_domain=translate.googleapis.com"
set "hosts_file=C:\Windows\System32\drivers\etc\hosts"
::for /f "skip=4 tokens=2" %%a in ('"nslookup %source_domain% 2>NUL"') do set ip=%%a
set "ip=172.253.124.90"
set "old_rule=null"
set "new_rule=%ip% %target_domain%"
for /f "tokens=*" %%i in ('type %hosts_file%') do (
    set "line=%%i"
    :: Retrieve the rule If the target domain has been exists in the line.
    if not "!line:%target_domain%=!"=="%%i" set "old_rule=%%i"
)
if not "%old_rule%"=="null" (
    if not "%old_rule%"=="%new_rule%" (
        echo Deleting the rule "%old_rule%"
        echo Adding the rule "%new_rule%"
        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%"
            >>%hosts_file% echo(!rule!
        )
    ) else (
        echo The rule already exists, nothing to do.
    )
) else (
    echo Adding the rule "%new_rule%"
    echo.>>%hosts_file%
    echo.>>%hosts_file%
    echo # Fix Google Translate CN>>%hosts_file%
    echo %new_rule%>>%hosts_file%
)
@ipconfig /flushdns
@echo   "修改谷歌翻译和刷新dns完成,请关闭!"
echo Done.
pause

 

标签:翻译,google,网页,%%,rule,echo,set,hosts,rule%
From: https://www.cnblogs.com/zy127/p/16891950.html

相关文章