// ==UserScript== // @name YouTube - Block Autoplay Preview // @name:vi YouTube - Chặn Preview Tự Động Khi Hover // @namespace https://greasyfork.org/users/979364-miebie-1412 // @version 1.1 // @description Blocks thumbnail hover previews (WebP & video) on all YouTube pages. Keeps progress badges and play buttons. // @description:vi Chặn hiệu ứng xem trước khi hover thumbnail trên mọi trang YouTube. Giữ badge tiến độ và nút play. // @author miebie.1412 // @match https://www.youtube.com/* // @match http://www.youtube.com/* // @match https://youtube.com/* // @match http://youtube.com/* // @grant none // @run-at document-start // @license MIT // @homepageURL https://greasyfork.org/en/users/979364-miebie-1412 // @supportURL https://greasyfork.org/en/users/979364-miebie-1412 // @downloadURL none // ==/UserScript== (function () { 'use strict'; // Inject CSS to hide preview elements const css = ` ytd-moving-thumbnail-renderer, ytd-thumbnail-overlay-resume-playback-renderer, ytd-thumbnail-overlay-loading-preview-renderer, ytd-video-preview, video[src*="an_webp"], video[src*="video-preview"], img[src*="an_webp"], img[src*="video-preview"] { display: none !important; } ytd-thumbnail img { opacity: 1 !important; } ytd-thumbnail-overlay-resume-playback-renderer[style*="width"], #thumbnail-overlay-play { display: block !important; } `; // Append style to head const style = document.createElement('style'); style.textContent = css; (document.head || document.documentElement).appendChild(style); // Clean dynamic preview sources const clean = () => { document.querySelectorAll('img[src*="an_webp"], img[src*="video-preview"], video[src*="an_webp"], video[src*="video-preview"]').forEach(el => { if (el.tagName == 'IMG') { el.src = el.src.replace(/an_webp\/[^&]*&/g, '').replace(/video-preview\/[^&]*&/g, ''); el.srcset = ''; } else if (el.tagName == 'VIDEO') { el.pause(); el.src = ''; } }); }; // Run on DOM ready if (document.readyState == 'loading') { document.addEventListener('DOMContentLoaded', clean); } else { clean(); } // Observe DOM changes new MutationObserver(clean).observe(document.documentElement, { childList: true, subtree: true, attributes: true, attributeFilter: ['src', 'srcset'] }); // Fallback interval setInterval(clean, 500); })();