谷歌删除了吗google.translate.SectionalElement?
\xd0\xa1ode 如下所示停止工作:
\n<script>\nfunction googleSectionalElementInit() {\n new google.translate.SectionalElement({\n sectionalNodeClassName: \'can-translate\',\n controlNodeClassName: \'translation-control\',\n }, \'google_sectional_element\');\n}\n</script>\n<script src="https://translate.google.com/translate_a/element.js?cb=googleSectionalElementInit"></script>\n\nRun Code Online (Sandbox Code Playgroud)\n也许有人宣布他们停止支持它?
\nGoogle翻译已停止在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>
Run Code Online (Sandbox Code Playgroud)
目前这是错误的:
跨域读取阻止(CORB)阻止了MIME类型为application / json的跨域响应https://translate.googleapis.com/translate_a/l?client=te&alpha=true&hl=zh-CN&cb=_callbacks____0jtqeel7c。有关更多详细信息,请参见https://www.chromestatus.com/feature/5629709824032768。
如果转到建议的链接,则建议:
确保使用下面列表中的正确“ Content-Type”响应标头以及“ X-Content-Type-Options:nosniff”响应标头为这些资源提供服务。
在https://translate.google.com/intl/zh-CN/about/website/上也有消息
我们不再为Google翻译的网站翻译器提供新的访问权限。此更改不会影响网站翻译器的现有使用。
这仅在Chrome中起作用,上面的代码仅在Google中起作用,我不知道在何处以及如何添加。"X-Content-Type-Options: nosniff"
UPD:有两个必要的标头。
Google是否封锁自己,是否有人知道如何解决?
UPD1:Google翻译错误也开始出现,并且在Firefox 66.0.1中也开始出现。它是
由于MIME类型(“ application / json”)不匹配(X-Content-Type-Options),来自“ https://translate.googleapis.com/translate_a/l?client=te&alpha=true&hl=en&cb=_callbacks____0jttrta1j ” 的资源已被阻止:nosniff)。
看起来有些翻译服务故障,在刷新一页后可以正常工作,在另一页上刷新-服务器返回错误的数据,json而不是javascript或类似的内容