[⚡NEW ANTI-DETECT]⚡NextSheild - Adblocker For Youtube

NextShield 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.

ของเมื่อวันที่ 13-09-2025 ดู เวอร์ชันล่าสุด

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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      NextShield - YouTube 广告拦截器
// @name:es      NextShield - Bloqueador de Anuncios de YouTube
// @name:hi      NextShield - YouTube विज्ञापन ब्लॉकर
// @name               [⚡NEW ANTI-DETECT]⚡NextSheild - Adblocker For Youtube
// @name:vi      NextSheild - Công cụ bỏ qua quảng cáo
// @namespace          https://twisk.com
// @version            1.0.4
// @description:zh-CN   NextShield屏蔽所有YouTube广告,让您无需干扰、快速且私密地观看视频。
// @description:es   NextShield bloquea todos los anuncios de YouTube, permitiéndote ver videos sin interrupciones y de forma privada.
// @description:hi   NextShield सभी YouTube विज्ञापनों को ब्लॉक करता है, जिससे आप बिना रुकावट, तेज़ और निजी तरीके से वीडियो देख सकते हैं।
// @description        NextShield 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 NextSheild 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             Airplane Mode - airpl4ne
// @icon               https://github.com/pillowslua/crackduo/blob/main/logo.png?raw=true
// @match              https://www.youtube.com/*
// @match              https://m.youtube.com/*
// @grant              none
// @license            MIT
// @noframes
// ==/UserScript==

// if you need support or you want help , please contact us!
// discord : t1wsk
// discord server : https://discord.gg/m3EV55SpYw
// we're going to make a YoutubeAdblocking API for free , if you want to use it , just contact us!
// big thanks to airpl4ne for giving me ideas & free codes!

(function() {
    'use strict';

    // css
    function applyMinimalStyles() {
        const style = document.createElement('style');
        style.textContent = `
            /* Notification styling */
            .simple-notification {
                position: fixed;
                top: 20px;
                right: 20px;
                padding: 10px 20px;
                background: #333;
                color: #fff;
                border-radius: 8px;
                box-shadow: 0 2px 8px rgba(0,0,0,0.2);
                z-index: 10000;
                font-family: Arial, sans-serif;
                font-size: 14px;
                opacity: 0;
                transform: translateY(-10px);
                transition: opacity 0.5s ease, transform 0.5s ease;
            }
            .simple-notification.show {
                opacity: 1;
                transform: translateY(0);
            }
        `;
        document.head.appendChild(style);
    }

    // notify
    function showNotification(message) {
        const notification = document.createElement('div');
        notification.className = 'simple-notification';
        notification.textContent = message;
        document.body.appendChild(notification);

        // fade in
        setTimeout(() => {
            notification.classList.add('show');
        }, 100);

        // fade out & removing notifi
        setTimeout(() => {
            notification.classList.remove('show');
            setTimeout(() => notification.remove(), 500);
        }, 3000);
    }

    // boost your video fps
    function enhanceVideoQuality() {
        const player = document.querySelector('video');
        if (!player || player.dataset.qualityEnhanced) return;

        // Access YouTube player API
        const ytPlayer = document.querySelector('#movie_player');
        if (!ytPlayer || !ytPlayer.getAvailableQualityLevels) return;

        // Mark as enhanced to prevent repeated attempts
        player.dataset.qualityEnhanced = 'true';

        // Get available quality levels
        const qualities = ytPlayer.getAvailableQualityLevels();
        // Prioritize highest quality (e.g., 'hd2160' for 4K, 'hd1080' for 1080p)
        const preferredQualities = ['hd2160', 'hd1440', 'hd1080', 'hd720', 'large', 'medium', 'small'];
        let selectedQuality = null;

        for (const quality of preferredQualities) {
            if (qualities.includes(quality)) {
                selectedQuality = quality;
                break;
            }
        }

        if (selectedQuality) {
            ytPlayer.setPlaybackQualityRange(selectedQuality);
            showNotification(`Video quality set to ${selectedQuality}!`);
        } else {
            showNotification('No higher quality available.');
        }

        // Attempt to prioritize high FPS (e.g., 60fps) by checking available streams
        // Note: YouTube's API doesn't directly expose FPS, so we infer from quality labels
        const playbackData = ytPlayer.getVideoData();
        if (playbackData && playbackData.isLive) {
            showNotification('Live stream detected; FPS optimization skipped.');
            return;
        }

        // Re-check available qualities after setting to ensure high FPS
        const qualityLabels = ytPlayer.getAvailableQualityLevels();
        const highFpsQuality = qualityLabels.find(q => q.includes('1080p60') || q.includes('720p60'));
        if (highFpsQuality && highFpsQuality !== selectedQuality) {
            ytPlayer.setPlaybackQualityRange(highFpsQuality);
            showNotification(`Switched to ${highFpsQuality} for higher FPS!`);
        }
    }

    // Ad-blocking functions
    function removeAntiAdblockPopup() {
        document.querySelectorAll('tp-yt-paper-dialog').forEach(dlg => {
            const isAdblockWarning =
                dlg.querySelector('a[href*="support.google.com"]') ||
                /adblock|allow\s*ads|blocker/i.test(dlg.innerText);

            if (isAdblockWarning) {
                console.log("[Userscript] Popup anti-adblock détecté → suppression.");
                dlg.remove();
                document.body.style.overflow = "auto";
                showNotification('Anti-adblock popup removed!');
            }
        });

        const backdrop = document.querySelector('tp-yt-iron-overlay-backdrop.opened');
        if (backdrop) {
            backdrop.remove();
            document.body.style.overflow = "auto";
        }
    }

    function bypassAgeRestriction() {
        const ageDialog = document.querySelector('ytd-enforcement-message-view-model');
        const player = document.querySelector('video');

        if (ageDialog) {
            ageDialog.remove();
            showNotification('Age restriction bypassed!');
        }

        if (player && player.paused && player.readyState === 0) {
            const isAgeBlocked = !!document.querySelector('ytd-player .ytd-watch-flexy[ad-blocked]');
            const videoId = new URLSearchParams(window.location.search).get('v');
            if (isAgeBlocked && videoId) {
                window.location.href = `https://www.youtube-nocookie.com/embed/${videoId}?autoplay=1`;
            }
        }
    }

    function skipAds() {
        const pipMode = document.querySelector('ytd-pip-container, ytd-miniplayer-player-container');
        const adVideo = document.querySelector('.ad-showing video');
        if (adVideo && adVideo.duration) {
            adVideo.currentTime = adVideo.duration;
            adVideo.muted = true;
            showNotification('Ad skipped!');
        }
        const skipBtn = document.querySelector('.ytp-ad-skip-button, .ytp-ad-skip-button-modern');
        if (skipBtn) {
            skipBtn.click();
            showNotification('Ad skipped!');
        }

        if (document.querySelector('.ad-showing')) {
            setTimeout(skipAds, 500);
        }
    }

    function removeAdBanners() {
        const selectors = [
            '#player-ads', '#masthead-ad', '.ytp-ad-overlay-container',
            '.ytp-ad-image-overlay', '.yt-mealbar-promo-renderer',
            '.ytp-featured-product', 'ytd-merch-shelf-renderer', 'ytd-in-feed-ad-layout-renderer',
            'ytd-engagement-panel-section-list-renderer'
        ];
        selectors.forEach(sel => {
            document.querySelectorAll(sel).forEach(el => {
                el.remove();
                showNotification('Ad banner removed!');
            });
        });
    }

    function keepVideoPlayingEarly() {
        const video = document.querySelector('video');
        if (!video || video.dataset.keepPlayingEarly) return;

        video.dataset.keepPlayingEarly = "true";

        const onPause = () => {
            if (video.currentTime <= 5) {
                video.play().then(() => {
                    showNotification('Video kept playing!');
                }).catch(err => {
                    console.warn("[Userscript] Impossible de play :", err);
                });
            }
        };
        video.removeEventListener('pause', onPause);
        video.addEventListener('pause', onPause);
    }

    // Initialize functionality
    applyMinimalStyles();

    let debounceTimeout;
    const observer = new MutationObserver(() => {
        clearTimeout(debounceTimeout);
        debounceTimeout = setTimeout(() => {
            removeAntiAdblockPopup();
            bypassAgeRestriction();
            skipAds();
            removeAdBanners();
            keepVideoPlayingEarly();
            enhanceVideoQuality();
        }, 100);
    });

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