// ==UserScript== // @name YouTube Premium // @version 1.13 // @description Enable YouTube Premium Logo // @match *://www.youtube.com/* // @grant none // ==/UserScript== (() => { const S = ``; document.head.appendChild(document.createElement('style')).textContent = `yt-icon.ytd-logo,c3-icon.yt-spec-more-drawer-view-model__more-drawer-header-logo{width:101px!important;height:20px!important}`; const premLogo = new DOMParser().parseFromString(S, "image/svg+xml").documentElement; premLogo.setAttribute('data-prem', '1'); const regex = /\bYouTube\b(?! Premium)/; const run = () => { const targets = document.querySelectorAll('ytd-topbar-logo-renderer, c3-icon.yt-spec-more-drawer-view-model__more-drawer-header-logo'); targets.forEach(el => { // 1. Hide doodle, country code if (el.tagName.startsWith('YTD')) { const y = el.querySelector('ytd-yoodle-renderer'); if (y) y.hidden = true; el.querySelectorAll('div[hidden], #country-code').forEach(e => e.hidden = false); } // 2. Swap icon const icon = el.matches('c3-icon') ? el : el.querySelector('yt-icon#logo-icon'); if (icon && !icon.querySelector('[data-prem]')) icon.replaceChildren(premLogo.cloneNode(true)); // 3. Update tooltip const a = el.closest('a') || el.querySelector('a#logo'); if (a) { const t = (a.title || a.getAttribute('aria-label') || '').replace(regex, 'YouTube Premium'); if (t && t !== a.title) { a.title = t; a.setAttribute('aria-label', t); } } }); }; let frame; const obs = new MutationObserver(() => { if (frame) cancelAnimationFrame(frame); frame = requestAnimationFrame(run); }); obs.observe(document.body, { subtree: true, childList: true }); window.addEventListener('yt-navigate-finish', run); run(); })();