修复谷歌浏览器翻译插件无法使用的问题

前几天谷歌不是发通知说因为中国大陆使用量太少,停止给谷歌翻译提供服务(信你个鬼,糟老头子坏得很)了吗?

但是咱们时不能这么轻易就让这个神器寄了的(虽然有另外个deepl翻译神器,效果貌似比谷歌还要好,但是无奈这个网站实在是太慢,就用的比较少),所以通过博众家之所长,知道了解决谷歌翻译无法使用的问题的方法。

从此谷歌翻译原地复活,嘻嘻!

方法很简单,就是把下面的代码复制到一个新建的txt文件后,把后缀名改成’’ .bat ‘’,然后右键单击用管理员运行模式运行该批处理文件即可。原理就是通过获得谷歌翻译的动态主机来提供服务。

格么,今朝的分享就到此位置了,如果您喜欢,欢迎点赞+关注+收藏!

:: 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

@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 "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%
)

echo Done.
pause

  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Haleine

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值