強制去除「沉浸式翻譯」翻譯Youtube字幕時的提示

隱藏「沉浸式翻譯」翻譯YouTube字幕時出現的 [ 雙語字幕由沉浸式翻譯支援 ] 字樣

// ==UserScript==
// @name         強制去除「沉浸式翻譯」翻譯Youtube字幕時的提示
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  隱藏「沉浸式翻譯」翻譯YouTube字幕時出現的 [ 雙語字幕由沉浸式翻譯支援 ] 字樣
// @author       shanlan(ChatGPT o3-mini)
// @match        *://*.youtube.com/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function(){
  function hideInShadow(shadow) {
    var style = document.createElement("style");
    style.textContent = ".loading-text.imt-cue { display: none !important; }";
    shadow.appendChild(style);
  }
  function processNode(node) {
    if(node.shadowRoot) { hideInShadow(node.shadowRoot); }
    var hosts = node.querySelectorAll('*');
    hosts.forEach(function(el){
      if(el.shadowRoot){ hideInShadow(el.shadowRoot); }
    });
  }
  document.querySelectorAll('*').forEach(function(el){ processNode(el); });
  var observer = new MutationObserver(function(mutations){
    mutations.forEach(function(mutation){
      mutation.addedNodes.forEach(function(added){
        if(added.nodeType === 1) { processNode(added); }
      });
    });
  });
  observer.observe(document.documentElement, { childList: true, subtree: true });
})();