[🔍Bypass Age & Anti-Detected🔒] YouTube Adblocker

[🔍Bypass Age & Anti-Detected🔒] AdGuard For YouTube blocks all YouTube ads, letting you watch videos uninterrupted, faster, and privately for a smooth, ad-free viewing experience, boost your FPS while streaming videos.

As of 05.10.2025. See апошняя версія.

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 or Violentmonkey 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.

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

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

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

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

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

// ==UserScript==
// @name:zh-CN      [🔍Bypass Age & Anti-Detected🔒] AdGuard For YouTube - YouTube 广告拦截器
// @name:es        [🔍Bypass Age & Anti-Detected🔒] AdGuard For YouTube - Bloqueador de Anuncios de YouTube
// @name:hi        [🔍Bypass Age & Anti-Detected🔒] AdGuard For YouTube - YouTube विज्ञापन ब्लॉकर
// @name           [🔍Bypass Age & Anti-Detected🔒] YouTube Adblocker
// @name:vi        [🔍Bypass Age & Anti-Detected🔒] AdGuard For YouTube - Công cụ bỏ qua quảng cáo
// @namespace      https://twisk.com
// @version        1.1.5
// @description:zh-CN   [🔍Bypass Age & Anti-Detected🔒] AdGuard For YouTube屏蔽所有YouTube广告,让您无需干扰、快速且私密地观看视频。
// @description:es       [🔍Bypass Age & Anti-Detected🔒] AdGuard For YouTube bloquea todos los anuncios de YouTube, permitiéndote ver videos sin interrupciones y de forma privada.
// @description:hi       [🔍Bypass Age & Anti-Detected🔒] AdGuard For YouTube सभी YouTube विज्ञापनों को ब्लॉक करता है, जिससे आप बिना रुकावट, तेज़ और निजी तरीके से वीडियो देख सकते हैं।
// @description         [🔍Bypass Age & Anti-Detected🔒] AdGuard For YouTube blocks all YouTube ads, letting you watch videos uninterrupted, faster, and privately for a smooth, ad-free viewing experience, boost your FPS while streaming videos.
// @description:vi      [🔍Bypass Age & Anti-Detected🔒] AdGuard For YouTube chặn tất cả YouTube quảng cáo, tạo trải nghiệm xem video nhanh hơn, bảo mật hơn, không quảng cáo.
// @author             airpl4ne
// @author w_irylis
// @icon               https://i.ibb.co/k6kVh2wf/Untitled-design.png
// @match              https://www.youtube.com/*
// @match              https://m.youtube.com/*
// @grant              none
// @license            MIT
// @noframes
// ==/UserScript==

// 💲Free Adblocker API at our Discord : https://discord.gg/Gvmd7deFtS
// 💦Free-To-Use , No Money Cost !
(function () {
    'use strict';

    let lastSkipTime = 0;
    const SKIP_DELAY = 500;

    function skipAds() {
        const player = document.querySelector('#movie_player, .html5-video-player');
        if (!player) return;

        const adIsPlaying =
            player.classList.contains('ad-showing') ||
            player.classList.contains('ad-interrupting') ||
            document.querySelector('.video-ads, .ytp-ad-module, .ytp-ad-text, .ytp-ad-preview');

        if (!adIsPlaying) return;

        const now = Date.now();
        if (now - lastSkipTime < SKIP_DELAY) return;

        const video = player.querySelector('video');
        if (video && video.duration) {
            const looksLikeAd =
                video.duration < 60 ||
                document.querySelector('.ytp-ad-text, .ytp-ad-skip-button-container, .ytp-ad-preview');

            if (looksLikeAd && !video.ended) {
                video.currentTime = video.duration;
                video.muted = true;
                lastSkipTime = now;
            } else {
                return;
            }
        }

        const skipButtons = [
            '.ytp-ad-skip-button',
            '.ytp-ad-skip-button-modern',
            '.ytp-skip-ad-button',
            'button.ytp-ad-skip-button',
            '.ytp-ad-overlay-close-button',
        ];

        skipButtons.forEach(selector => {
            const found = document.querySelectorAll(selector);
            found.forEach(btn => {
                if (btn.offsetParent !== null) {
                    btn.click();
                }
            });
        });

        if (player.classList.contains('ad-showing') || player.classList.contains('ad-interrupting')) {
            player.classList.remove('ad-showing', 'ad-interrupting');
        }

        if (video && video.paused) {
            video.play().catch(() => console.log('Error resuming video after ad.'));
        }
    }

    function removeAdElements() {
        const adSelectors = [
            'ytd-in-feed-ad-layout-renderer',
            'ytd-ad-slot-renderer',
            '#player-ads',
            '#masthead-ad',
            '.ytp-featured-product',
            'ytd-companion-slot-renderer',
            'ytd-player-legacy-desktop-watch-ads-renderer',
        ];

        adSelectors.forEach(selector => {
            document.querySelectorAll(selector).forEach(el => {
                if (el && el.parentNode) {
                    el.parentNode.removeChild(el);
                }
            });
        });

        const relatedItems = document.querySelectorAll('#related ytd-rich-item-renderer');
        relatedItems.forEach(item => {
            if (
                item.querySelector('ytd-ad-slot-renderer, [class*="ad"], [class*="sponsored"]') &&
                item.parentNode
            ) {
                item.parentNode.removeChild(item);
            }
        });
    }

    function bypassAgeGate() {
        const url = window.location.href;
        const ageMessage = document.querySelector(
            '.ytp-error-content, .ytp-error, [aria-label*="age-restricted"]'
        );

        if (ageMessage && url.includes('watch?v=')) {
            const videoId = url.match(/v=([^&]+)/)?.[1];
            if (videoId) {
                const newUrl = `https://www.youtube-nocookie.com/embed/${videoId}`;
                window.location.href = newUrl;
            } else {
                console.log('Could not find video ID in URL.');
            }
        } else if (url.includes('/v/')) {
            const player = document.querySelector('#movie_player, .html5-video-player');
            const video = player?.querySelector('video');
            if (video && video.paused) {
                video.play().catch(() => console.log('Error trying to play age-restricted video.'));
            }
        }
    }

    function handleAll() {
        try {
            skipAds();
            removeAdElements();
            bypassAgeGate();
        } catch (err) {
            console.log('Error while handling ads or restrictions:', err);
        }
    }

    function setupObserver() {
        const observer = new MutationObserver(mutations => {
            if (mutations.length > 50) return;
            handleAll();
        });

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

        console.log('Mutation observer is running to detect ads.');
    }

    window.addEventListener('load', () => {
        console.log('Page loaded, ad handler started.');
        handleAll();
        setupObserver();
    });

    handleAll();

    setInterval(handleAll, 1000);
})();