{"id":1086,"date":"2022-10-09T11:41:22","date_gmt":"2022-10-09T03:41:22","guid":{"rendered":"https:\/\/benson.ml\/?p=1086"},"modified":"2022-10-09T11:45:43","modified_gmt":"2022-10-09T03:45:43","slug":"%e5%a6%82%e4%bd%95%e6%81%a2%e5%a4%8d-chrome-%e7%bf%bb%e8%af%91%e5%8a%9f%e8%83%bd%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/benson80.eu.org\/?p=1086","title":{"rendered":"\u5982\u4f55\u6062\u590d Chrome \u7ffb\u8bd1\u529f\u80fd\uff1f"},"content":{"rendered":"\n<p>\u4e0b\u9762\u662f\u83b7\u53d6\u53ef\u7528 IP \u5730\u5740\u4ee5\u53ca\u4fee\u6539 Windows \u7cfb\u7edfhosts \u6587\u4ef6\u7684\u81ea\u52a8\u5316\u811a\u672c\u4ee3\u7801\uff1a<\/p>\n\n\n\n<p>\u811a\u672c\u6258\u7ba1\u5728&nbsp;<a href=\"https:\/\/gist.github.com\/bookfere\/c9baf1d03d6f488c7033effbd541e628\" target=\"_blank\" rel=\"noreferrer noopener\">GitHub Gist<\/a>&nbsp;\u4e0a\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7\u94fe\u63a5\u76f4\u63a5\u4e0b\u8f7d\u5230\u672c\u5730\u4f7f\u7528\u3002<\/p>\n\n\n\n<p>\u628a\u4ee3\u7801\u4fdd\u5b58\u4e3abat\u6587\u4ef6\uff0c\u6700\u540e\u4ee5\u7ba1\u7406\u5458\u8eab\u4efd\u8fd0\u884c\u811a\u672c\u5373\u53ef\u5b8c\u6210\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">:: Copyright (c)2022 https:\/\/bookfere.com\n:: This is a batch script for fixing Google Translate and making it available\n:: in the Chinese mainland. If you experience any problem, visit the page below:\n:: https:\/\/bookfere.com\/post\/1020.html\n\n@echo off\nsetlocal enabledelayedexpansion\nchcp 437 &gt;NULL\n\nset \"source_domain=google.cn\"\nset \"target_domain=translate.googleapis.com\"\n\nset \"hosts_file=C:\\Windows\\System32\\drivers\\etc\\hosts\"\nfor \/f \"skip=4 tokens=2\" %%a in ('\"nslookup %source_domain% 2&gt;NUL\"') do set ip=%%a\nset \"old_rule=null\"\nset \"new_rule=%ip% %target_domain%\"\nset \"comment=# Fix Google Translate CN\"\n\nfor \/f \"tokens=*\" %%i in ('type %hosts_file%') do (\n    set \"line=%%i\"\n    :: Retrieve the rule If the target domain exists.\n    if not \"!line:%target_domain%=!\"==\"%%i\" set \"old_rule=%%i\"\n)\n\nif not \"%old_rule%\"==\"null\" (\n    echo A rule has been added to the hosts file. \n    echo [1] Update [2] Delete\n    set \/p action=\"Enter a number to choose an action: \"\n    if \"!action!\"==\"1\" (\n        if not \"%old_rule%\"==\"%new_rule%\" (\n            echo Deleting the rule \"%old_rule%\"\n            echo Adding the rule \"%new_rule%\"\n            set \"new_line=false\"\n            for \/f \"tokens=*\" %%i in ('type %hosts_file% ^| find \/v \/n \"\" ^&amp; break ^&gt; %hosts_file%') do (\n                set \"rule=%%i\"\n                set \"rule=!rule:*]=!\"\n                if \"%old_rule%\"==\"!rule!\" set \"rule=%new_rule%\"\n                if \"!new_line!\"==\"true\" &gt;&gt;%hosts_file% echo.\n                &gt;&gt;%hosts_file% &lt;NUL set \/p=\"!rule!\"\n                set \"new_line=true\"\n            )\n        ) else (\n            echo The rule already exists, nothing to do.\n        )\n    )\n    if \"!action!\"==\"2\" (\n        echo Deleting the rule \"%old_rule%\"\n        set \"new_line=false\"\n        for \/f \"tokens=*\" %%i in ('\n            type \"%hosts_file%\" ^| findstr \/v \/c:\"%comment%\" ^| findstr \/v \"%target_domain%\" ^| find \/v \/n \"\" ^&amp; break ^&gt; \"%hosts_file%\"\n        ') do (\n            set \"line=%%i\"\n            set \"line=!line:*]=!\"\n            if \"!new_line!\"==\"true\" &gt;&gt;%hosts_file% echo.\n            &gt;&gt;%hosts_file% &lt;NUL set \/p=\"!line!\"\n            set \"new_line=true\"\n        )\n    )\n) else (\n    echo Adding the rule \"%new_rule%\"\n    echo.&gt;&gt;%hosts_file%\n    echo %comment%&gt;&gt;%hosts_file%\n    &lt;NUL set \/p=\"%new_rule%\"&gt;&gt;%hosts_file%\n)\n\necho Done.\npause<\/pre>\n\n\n\n<p>Github \u5f00\u6e90\u9879\u76ee\u5730\u5740\uff1a<a href=\"https:\/\/gist.github.com\/bookfere\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/gist.github.com\/bookfere<\/a><\/p>\n\n\n\n<p>\u9700\u8981\u6ce8\u610f\u7684\u662f\uff1a\u79d1\u5b66\u4e0a\u7f51\u5fc5\u987b\u6253\u5f00\u5168\u5c40\u4ee3\u7406\uff0c\u5426\u5219\u8fd8\u662f\u65e0\u6cd5\u4f7f\u7528\u7ffb\u8bd1\u529f\u80fd\u3002<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e0b\u9762\u662f\u83b7\u53d6\u53ef\u7528 IP \u5730\u5740\u4ee5\u53ca\u4fee\u6539 Windows &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-1086","post","type-post","status-publish","format-standard","hentry","category-windows"],"_links":{"self":[{"href":"https:\/\/benson80.eu.org\/index.php?rest_route=\/wp\/v2\/posts\/1086","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/benson80.eu.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/benson80.eu.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/benson80.eu.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/benson80.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1086"}],"version-history":[{"count":3,"href":"https:\/\/benson80.eu.org\/index.php?rest_route=\/wp\/v2\/posts\/1086\/revisions"}],"predecessor-version":[{"id":1091,"href":"https:\/\/benson80.eu.org\/index.php?rest_route=\/wp\/v2\/posts\/1086\/revisions\/1091"}],"wp:attachment":[{"href":"https:\/\/benson80.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1086"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/benson80.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1086"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/benson80.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1086"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}