VK Blur Exterminator

Removes blur layers and age-restriction overlays, fills blank thumbnail previews on VK.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

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

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name        VK Blur Exterminator
// @namespace   Violentmonkey Scripts
// @version     1.1.0
// @license     MIT
// @match       https://m.vkvideo.ru/*
// @match       https://www.vkvideo.ru/*
// @match       https://vkvideo.ru/*
// @grant       none
// @run-at      document-start
// @author      tarangogo
// @description Removes blur layers and age-restriction overlays, fills blank thumbnail previews on VK.
// ==/UserScript==
(function () {
    'use strict';

    /* ── CSS ── */
    const style = document.createElement('style');
    style.textContent = `
        [class*="VideoCardRestrictionOverlay"],
        [class*="VideoPreviewOverlay"],
        [class*="RestrictionOverlay"],
        [class*="AgeRestriction"],
        [class*="adult_warning"] {
            display: none !important;
        }
        [class*="VideoCard"] img,
        [class*="VideoCard"] video,
        [class*="videoCard"] img,
        [class*="videoCard"] video {
            filter: none !important;
            backdrop-filter: none !important;
            -webkit-backdrop-filter: none !important;
        }
        [style*="blur"] {
            filter: none !important;
            backdrop-filter: none !important;
            -webkit-backdrop-filter: none !important;
        }
        /* Force preview image containers to be visible */
        [class*="VideoCardPreviewImage__container"] {
            opacity: 1 !important;
            visibility: visible !important;
            display: block !important;
        }
    `;

    const injectStyle = () => {
        (document.head || document.documentElement).appendChild(style);
    };

    if (document.head) {
        injectStyle();
    } else {
        new MutationObserver((_, obs) => {
            if (document.head) {
                injectStyle();
                obs.disconnect();
            }
        }).observe(document.documentElement, { childList: true });
    }

    /* ── JS ── */
    const OVERLAY_PATTERNS = [
        'VideoCardRestrictionOverlay',
        'VideoPreviewOverlay',
        'RestrictionOverlay',
        'AgeRestriction',
        'adult_warning',
        'hide_outline_28',
    ];

    const removeOverlays = () => {
        OVERLAY_PATTERNS.forEach(pattern => {
            document.querySelectorAll(`[class*="${pattern}"]`).forEach(el => {
                const tag = el.tagName.toLowerCase();
                if (!['img', 'video', 'source'].includes(tag)) {
                    el.remove();
                }
            });
        });

        // Auto-click age-confirmation buttons
        document.querySelectorAll(
            'button[class*="confirm"], button[class*="Adult"], button[class*="adult"], button[class*="Confirm"]'
        ).forEach(btn => {
            if (btn.offsetParent !== null) btn.click();
        });

        // Strip inline blur styles
        document.querySelectorAll('[style*="blur"], [style*="filter"]').forEach(el => {
            el.style.removeProperty('filter');
            el.style.removeProperty('backdrop-filter');
            el.style.removeProperty('-webkit-backdrop-filter');
        });

        // Fix missing containerVisible class on preview image containers
        document.querySelectorAll('[class*="VideoCardPreviewImage__container"]').forEach(el => {
            const hasVisible = [...el.classList].some(c => c.includes('containerVisible'));
            if (!hasVisible) {
                const visibleEl = document.querySelector('[class*="containerVisible"]');
                if (visibleEl) {
                    const visibleClass = [...visibleEl.classList].find(c => c.includes('containerVisible'));
                    if (visibleClass) el.classList.add(visibleClass);
                } else {
                    el.style.opacity = '1';
                    el.style.visibility = 'visible';
                }
            }
        });
    };

    const start = () => {
        removeOverlays();
        new MutationObserver(removeOverlays).observe(document.body, {
            childList: true,
            subtree: true,
        });
    };

    if (document.body) {
        start();
    } else {
        document.addEventListener('DOMContentLoaded', start, { once: true });
    }
})();