NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Disable YouTube translation // @description Disabled this *** feature, keep original text. // @author BZHDeveloper // @license MIT // @version 1.0.3 // @match *://*.youtube.com/* // @downloadURL https://openuserjs.org/src/scripts/BZHDeveloper/Disable_YouTube_translation.user.js // @updateURL https://openuserjs.org/src/scripts/BZHDeveloper/Disable_YouTube_translation.user.js // @grant none // ==/UserScript== var infos = { run : false, title : null, title_ok : false, description : null, description_ok : false }; function Uri (data) { var link = document.createElement ("a"); link.href = data; this.scheme = link.protocol; this.host = link.hostname; this.port = 0; if (link.port.length > 0) this.port = parseInt(link.port); if (this.scheme == "http:" && this.port == 0) this.port = 80; if (this.scheme == "https:" && this.port == 0) this.port = 443; this.username = link.username; this.password = link.password; this.path = link.pathname; this.parameters = {}; if (link.search !== null && link.search.length > 0) { var q = link.search.substring(1); var p = q.split('&'); for (var i = 0; i < p.length; i++) { var k = p[i].split('=')[0]; if (p[i].indexOf('=') > 0) this.parameters[k] = p[i].split('=')[1]; else this.parameters[k] = null; } } if (link.hash !== null) this.fragment = link.hash.substring(1); this.toString = function (b) { var result = this.scheme + "//"; if (this.username != null && this.username.length > 0) { result += this.username; if (this.password != null && this.password.length > 0) result += (":" + this.password); result += "@"; } result += this.host; if (!(this.scheme == "http:" && this.port == 80 || this.scheme == "https:" && this.port == 443)) result += (":" + this.port); if (this.path != "/") result += this.path; if (b == false) return result; var search = []; for (var key in this.parameters) { search.push (key + "=" + this.parameters[key]); } if (search.length > 0) result += ("?" + search.join ("&")); if (this.fragment != null && this.fragment.toString().length > 0) result += ("#" + this.fragment); return result; } } var uri = new Uri (document.location.href); if (!uri.parameters.hasOwnProperty ("v")) return; var obs = new MutationObserver (function (mutations, observer) { if (infos.run == true) return; if (infos.title != null) { var title_element = null, desc_element = null; // *** polymer if (document.querySelector ("#container > h1 > yt-formatted-string") != null) { title_element = document.querySelector ("#container > h1 > yt-formatted-string"); desc_element = document.querySelector ("#description > yt-formatted-string"); } else { title_element = document.querySelector ("#eow-title"); desc_element = document.querySelector ("#eow-description"); } if (title_element != null && infos.title_ok == false) { title_element.textContent = infos.title; infos.title_ok = true; } if (desc_element != null && infos.description_ok == false) { desc_element.innerHTML = infos.description; infos.description_ok = true; } return; } infos.run = true; fetch ("https://www.youtube.com/watch?v=" + uri.parameters.v).then (response => { return response.text(); }).then (text => { var json = text.split ("window[\"ytInitialPlayerResponse\"] = (")[1].split (");")[0].trim(); var object = JSON.parse (json); infos.title = object.videoDetails.title; var desc = object.videoDetails.shortDescription; desc = desc.replace(/\n/g, "<br />"); [ " ", "<br />" ].forEach (str => { var array = desc.split (str); for (var i = 0; i < array.length; i++) { if (array[i].indexOf ("http://") == 0 || array[i].indexOf ("https://") == 0 || array[i].indexOf ("ftp://") == 0 || array[i].indexOf ("magnet:") == 0) array[i] = "<a href=\"" + array[i] + "\">" + array[i] + "</a>"; } desc = array.join (str); }); infos.description = desc; console.log (infos.description); infos.run = false; }); }); obs.observe (document, {attributes: false, childList: true, characterData: false, subtree: true});