NetEase Music Cloud Translator

Translate from the chinese to your language at music.163.com

目前为 2015-06-12 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @id NetEase_Music_Cloud_Translator
  3. // @name NetEase Music Cloud Translator
  4. // @namespace https://github.com/plablo/NetEase_music_translator
  5. // @version 0.3
  6. // @description Translate from the chinese to your language at music.163.com
  7. // @author Plablo
  8. // @include http://music.163.com/*
  9. // @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js
  10. // @compatible chrome
  11. // @compatible firefox
  12. // @grant none
  13. // @run-at document-end
  14. // ==/UserScript==
  15.  
  16. //*** Create google translator gadget ***
  17. //Make the container
  18. var container_div = document.createElement('div');
  19. container_div.style.position = 'absolute';
  20. container_div.style.zIndex = "999999";
  21. container_div.style.width = '100px';
  22. container_div.style.top = 0;
  23. container_div.style.left = 0;
  24.  
  25. //Make the gadget
  26. var google_tt_div = document.createElement('div');
  27. google_tt_div.id = 'google_translate_element';
  28. google_tt_div.innerHTML = '';
  29. container_div.appendChild(google_tt_div);
  30.  
  31. var google_tt_script = document.createElement('script'); //create a script tag
  32. google_tt_script.type = 'text/javascript'; // add type attribute
  33. google_tt_script.innerHTML = 'function googleTranslateElementInit() {new google.translate.TranslateElement({pageLanguage: \'zh-CN\', layout: google.translate.TranslateElement.InlineLayout.SIMPLE, autoDisplay: false, multilanguagePage: true}, \'google_translate_element\');}';
  34. container_div.appendChild(google_tt_script); // Insert it as the last child of body
  35.  
  36. var google_tt_script_link = document.createElement('script'); //create a script tag
  37. google_tt_script_link.type = 'text/javascript'; // add type attribute
  38. google_tt_script_link.src = '//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit';
  39. container_div.appendChild(google_tt_script_link); // Insert it as the last child of body
  40.  
  41. //Append to the end of the main body
  42. $('body').filter(function(){return this.id.match(/auto-id-./);}).get(0).appendChild(container_div);
  43.  
  44. //Hide the Google Translator Bar
  45. var node = document.createElement("style"); //iframe.goog-te-banner-frame.skiptranslate {display: none !important;} .skiptranslate {display: none !important;}
  46. var css = "iframe.goog-te-banner-frame {display: none !important;} #goog-gt-tt {display: none !important;} .goog-te-gadget {display: block !important;} body {top: 0px !important;}"
  47. node.type = "text/css";
  48. node.appendChild(document.createTextNode(css));
  49. var heads = document.getElementsByTagName("head");
  50. if (heads.length > 0) {
  51. heads[0].appendChild(node);
  52. } else {
  53. // no head yet, stick it whereever
  54. document.documentElement.appendChild(node);
  55. }

QingJ © 2025

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