Google 翻译已在 Chrome 停止工作

Google translate has stopped working in Chrome

Google 翻译已在 Chrome 中停止工作,但仍在 Firefox 中工作。代码如下,之前已经运行了很长时间:

<script>
    function googleSectionalElementInit() {
    new google.translate.SectionalElement({
        sectionalNodeClassName: 'can-translate',
        controlNodeClassName: 'translation-control',
        background: '#ffffcc'
    }, 'google_sectional_element');
    }
    var url = top.location.href,
        pos = url.search(/\/\w\w(\W|$)/),
        lang = url.substring(pos+1,pos+3),
    (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = false;
        ga.src = 'https://translate.google.com/translate_a/element.js?cb=googleSectionalElementInit&ug=section&hl='+lang;
        (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
    })();
</script>

目前这里是错误:

Cross-Origin Read Blocking (CORB) blocked cross-origin response https://translate.googleapis.com/translate_a/l?client=te&alpha=true&hl=en&cb=_callbacks____0jtqeel7c with MIME type application/json. See https://www.chromestatus.com/feature/5629709824032768 for more details.

如果去建议link,这里建议:

Make sure these resources are served with a correct "Content-Type" response header from the list below, as well as a "X-Content-Type-Options: nosniff" response header.

https://translate.google.com/intl/en/about/website/

也有留言

We no longer provide new access to Google Translate's Website Translator. This change does not affect existing use of the Website Translator.

这仅对 Chrome 有影响,上面的代码仅 Google 而且我不知道在哪里以及如何添加 "X-Content-Type-Options: nosniff".

UPD:有两个必要的headers。

Google 是否自行阻止,有人知道如何解决吗?

UPD1: Google 翻译错误开始出现在 Firefox 66.0.1 中。是

The resource from “https://translate.googleapis.com/translate_a/l?client=te&alpha=true&hl=en&cb=_callbacks____0jttrta1j” was blocked due to MIME type (“application/json”) mismatch (X-Content-Type-Options: nosniff).

看起来像是翻译服务出了点问题,一个页面刷新后它就可以工作了,然后另一个页面 - 服务器 returns 不正确的数据,json 而不是 javascript 或类似这样的东西

此时,如果您为主机."NID"手动删除一个名为"NID"的cookie,translate.googleapis.com,您可以处理该页面(CORB错误消失)

顺便说一下,重复的页面调用有时也会消除这个错误。但是问题的解决方法和它的出现一样奇怪。

请通过 https://crbug.com/new 打开错误并尝试提供尽可能多的详细信息:

  • 问题是否在 Chrome 72 时有效并在 Chrome 73 时停止?

  • 是否有显示问题的重现页面?预期 VS 观察到的行为是什么?

  • 问题是否在没有任何 Chrome 扩展的情况下重现?

  • 损坏的页面是否使用AppCache?

我在多个网站上都遇到过这个问题,它最初是在我的 Pixel 2 上 Chrome 上出现的。

小部件有时会出现在第一次加载时,如果不是,则只需重新加载,甚至不需要硬重新加载。我的猜测是 Google 正试图逐步淘汰该小部件。

该小部件在所有其他浏览器上仍然可以正常工作,没有任何问题。