Google网页翻译

不跳转Google翻译页面的整页翻译

  1. // ==UserScript==
  2. // @name Google网页翻译
  3. // @namespace https://gf.qytechs.cn/zh-CN/users/150560
  4. // @version 1.1
  5. // @description 不跳转Google翻译页面的整页翻译
  6. // @author 田雨菲
  7. // @match http://*/*
  8. // @include https://*/*
  9. // @include file://*/*
  10. // @run-at document-end
  11. // ==/UserScript==
  12.  
  13. (function () {
  14. 'use strict';
  15. var userLang = document.documentElement.lang;
  16. if (userLang!=="" && userLang.substr(0, 2) != "zh") {
  17. var script = document.createElement('script');
  18. script.src = '//translate.google.cn/translate_a/element.js?cb=googleTranslateElementInit';
  19. document.getElementsByTagName('head')[0].appendChild(script);
  20.  
  21. var google_translate_element = document.createElement('div');
  22. google_translate_element.id = 'google_translate_element';
  23. google_translate_element.style = 'position:fixed; bottom:10px; right:10px; cursor:pointer;';
  24. document.documentElement.appendChild(google_translate_element);
  25.  
  26. script = document.createElement('script');
  27. script.innerHTML = "function googleTranslateElementInit() {" +
  28. "new google.translate.TranslateElement({" +
  29. "layout: google.translate.TranslateElement.InlineLayout.SIMPLE," +
  30. "multilanguagePage: true," +
  31. "pageLanguage: 'auto'," +
  32. "includedLanguages: 'zh-CN,zh-TW,en'" +
  33. "}, 'google_translate_element');}";
  34. document.getElementsByTagName('head')[0].appendChild(script);
  35. }
  36. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址