NetEase Music Cloud Translator

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

  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.4.1
  6. // @description Translate from chinese to your language at music.163.com
  7. // @author Plablo
  8. // @license NetEase Music Cloud Translator is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
  9. // @include http://music.163.com/*
  10. // @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js
  11. // @compatible chrome
  12. // @compatible firefox
  13. // @grant none
  14. // @run-at document-end
  15. // ==/UserScript==
  16.  
  17. //*** Create google translator gadget ***
  18. //Make the container
  19. var container_div = document.createElement('div');
  20. container_div.style.position = 'absolute';
  21. container_div.style.zIndex = "999999";
  22. container_div.style.width = '100px';
  23. container_div.style.top = 0;
  24. container_div.style.left = 0;
  25.  
  26. //Make the gadget
  27. var google_tt_div = document.createElement('div');
  28. google_tt_div.id = 'google_translate_element';
  29. google_tt_div.innerHTML = '';
  30. container_div.appendChild(google_tt_div);
  31.  
  32. var google_tt_script = document.createElement('script'); //create a script tag
  33. google_tt_script.type = 'text/javascript'; // add type attribute
  34. 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\');}';
  35. container_div.appendChild(google_tt_script); // Insert it as the last child of container_div
  36.  
  37. var google_tt_script_link = document.createElement('script'); //create a script tag
  38. google_tt_script_link.type = 'text/javascript'; // add type attribute
  39. google_tt_script_link.src = '//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit';
  40. container_div.appendChild(google_tt_script_link); // Insert it as the last child of container_div
  41.  
  42. //Append to the end of the main body
  43. $('body').filter(function(){return this.id.match(/auto-id-./);}).get(0).appendChild(container_div);
  44.  
  45. //Hide the Google Translator Bar using CSS
  46. var node = document.createElement("style");
  47. 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;}"
  48. node.type = "text/css";
  49. node.appendChild(document.createTextNode(css));
  50. var heads = document.getElementsByTagName("head");
  51. if (heads.length > 0) {
  52. heads[0].appendChild(node);
  53. } else {
  54. // no head yet, stick it whereever
  55. document.documentElement.appendChild(node);
  56. }

QingJ © 2025

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