NetEase Music Cloud Translator

Translate from the chinese to your language

目前為 2015-06-11 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         NetEase Music Cloud Translator
// @namespace    https://github.com/plablo/NetEase_music_translator
// @version      0.2
// @description  Translate from the chinese to your language
// @author       Plablo
// @include      http://music.163.com/*
// @grant        none
// @run-at       document-end
// ==/UserScript==

//*** Create google translator gadget ***
//Make the container
var container_div = document.createElement('div');
container_div.style.position = 'absolute';
container_div.style.zIndex = "999999";
container_div.style.width = '100px';
container_div.style.top = 0;
container_div.style.left = 0;

//Make the gadget
var google_tt_div = document.createElement('div');
google_tt_div.id = 'google_translate_element';
google_tt_div.innerHTML = '';
container_div.appendChild(google_tt_div);

var google_tt_script = document.createElement('script'); //create a script tag
google_tt_script.type = 'text/javascript'; // add type attribute
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\');}';
container_div.appendChild(google_tt_script); // Insert it as the last child of body

var google_tt_script_link = document.createElement('script'); //create a script tag
google_tt_script_link.type = 'text/javascript'; // add type attribute
google_tt_script_link.src = '//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit';
container_div.appendChild(google_tt_script_link); // Insert it as the last child of body

//Append to the end
document.body.appendChild(container_div);

//Hide the Google Translator Bar
var node = document.createElement("style"); //iframe.goog-te-banner-frame.skiptranslate {display: none !important;} .skiptranslate {display: none !important;}
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;}" 
	node.type = "text/css";
	node.appendChild(document.createTextNode(css));
	var heads = document.getElementsByTagName("head");
	if (heads.length > 0) {
		heads[0].appendChild(node); 
	} else {
		// no head yet, stick it whereever
		document.documentElement.appendChild(node);
	}