Greasy Fork is available in English.

Move Preferred YouTube Subtitle Auto-translate Language Options To Top

Move preferred YouTube subtitle auto-translate languages to top of the list for quick access. Users who use non English (US) language in their YouTube setting, must manually edit the script for their chosen language.

Mint 2020.05.25.. Lásd a legutóbbi verzió

// ==UserScript==
// @name         Move Preferred YouTube Subtitle Auto-translate Language Options To Top
// @namespace    https://greasyfork.org/en/users/85671-jcunews
// @version      1.0.1
// @license      AGPLv3
// @author       jcunews
// @description  Move preferred YouTube subtitle auto-translate languages to top of the list for quick access. Users who use non English (US) language in their YouTube setting, must manually edit the script for their chosen language.
// @match        https://www.youtube.com/*
// @grant        none
// ==/UserScript==

(() => {

  //*** CONFIGURATION BEGIN ***

  //One or more menu titles for "Auto-translate". If YouTube language is not English (US), title must be specified according to current YouTube language.
  //For English (US) language, the menu title is "Auto-translate". So, if the language is French, the title must be "Traduire automatiquement".
  //Multiple titles can be specified as e.g.: ["Auto-translate", "Traduire automatiquement"]
  let menuTitle    = "Auto-translate";

  //One or more auto-translate language(s) to keep. Language names must also be specified according to current YouTube language.
  //For English (US) language, the language name for French is "French". But if the language is French, the language name for French must be "Français".
  //Multiple languages can be specified as e.g.: ["English", "French"]
  let keepLanguage = ["English"];

  //*** CONFIGURATION END ***

  (function waitPlayerSettingsMenu(a) {
    if (a = document.querySelector(".ytp-settings-menu")) {
      (new MutationObserver(recs => {
        recs.forEach(rec => {
          rec.addedNodes.forEach((nd, a) => {
            if (nd.querySelector && (a = nd.querySelector(".ytp-panel-title")) && menuTitle.includes(a.textContent)) {
              a = 0;
              nd.querySelectorAll(".ytp-menuitem:not([aria-checked])>.ytp-menuitem-label").forEach(l => {
                if (keepLanguage.includes(l.textContent)) (l = l.parentNode).parentNode.insertBefore(l, l.parentNode.children[a++]);
              });
            }
          });
        });
      })).observe(a, {childList: true});
    } else setTimeout(waitPlayerSettingsMenu, 100);
  })();
})();