Blur YouTube Videos with Shortcut

Apply a 100px blur effect to YouTube videos with Alt+Y

اعتبارا من 07-01-2025. شاهد أحدث إصدار.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==UserScript==
// @name         Blur YouTube Videos with Shortcut
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  Apply a 100px blur effect to YouTube videos with Alt+Y
// @author       Drewby123
// @match        *://www.youtube.com/*
// @license      MIT    
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    let isBlurred = false; // Track the blur state

    // Function to toggle the blur effect
    function toggleBlur() {
        const videos = document.querySelectorAll('video');
        isBlurred = !isBlurred;
        const blurValue = isBlurred ? 'blur(100px)' : 'none'; // Toggle blur
        videos.forEach(video => {
            video.style.filter = blurValue;
            video.style.transition = 'filter 0.5s'; // Smooth transition
        });
    }

    // Event listener for Alt+Y
    document.addEventListener('keydown', event => {
        if (event.altKey && event.key.toLowerCase() === 'y') {
            toggleBlur();
        }
    });

    // Apply blur to dynamically loaded videos
    const observer = new MutationObserver(() => {
        if (isBlurred) {
            const videos = document.querySelectorAll('video');
            videos.forEach(video => {
                video.style.filter = 'blur(100px)';
                video.style.transition = 'filter 0.5s';
            });
        }
    });

    observer.observe(document.body, {
        childList: true,
        subtree: true
    });
})();