VK Blur Exterminator

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

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey, Greasemonkey или Violentmonkey.

За да инсталирате този скрипт, трябва да инсталирате разширение, като например Tampermonkey .

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey или Violentmonkey.

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey или Userscripts.

За да инсталирате скрипта, трябва да инсталирате разширение като Tampermonkey.

За да инсталирате този скрипт, трябва да имате инсталиран скриптов мениджър.

(Вече имам скриптов мениджър, искам да го инсталирам!)

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

(Вече имам инсталиран мениджър на стиловете, искам да го инсталирам!)

// ==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 });
    }
})();