Greasy Fork

Greasy Fork is available in English.

YouTube - Block Autoplay Preview

Blocks thumbnail hover previews (WebP & video) on all YouTube pages. Keeps progress badges and play buttons.

当前为 2025-11-11 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name           YouTube - Block Autoplay Preview
// @name:vi        YouTube - Chặn Preview Tự Động Khi Hover
// @namespace      http://greasyfork.icu/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    http://greasyfork.icu/en/users/979364-miebie-1412
// @supportURL     http://greasyfork.icu/en/users/979364-miebie-1412
// ==/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);
})();