// ==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🔒] AdGuard For YouTube
// @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.3
// @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 !
/**
* YouTube Ad Skipper - Auto Skip Ads & Remove YouTube Ads
*
* Copyright (c) 2024+ Irylis STD
* Licensed under the MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
(function() {
'use strict';
let lastAdSkippedTime = 0;
const SKIP_COOLDOWN = 500;
function skipVideoAds() {
const player = document.querySelector('#movie_player, .html5-video-player');
if (!player) {
console.log('Video player not found');
return;
}
const isAdPlaying = player.classList.contains('ad-showing') ||
player.classList.contains('ad-interrupting') ||
document.querySelector('.video-ads, .ytp-ad-module, .ytp-ad-text, .ytp-ad-preview');
if (!isAdPlaying) {
return;
}
const currentTime = Date.now();
if (currentTime - lastAdSkippedTime < SKIP_COOLDOWN) {
console.log('Skip ignored: cooldown active');
return;
}
const video = player.querySelector('video');
if (video && video.duration) {
const isLikelyAd = video.duration < 60 ||
document.querySelector('.ytp-ad-text, .ytp-ad-skip-button-container, .ytp-ad-preview');
if (isLikelyAd && !video.ended) {
video.currentTime = video.duration;
video.muted = true;
lastAdSkippedTime = currentTime;
console.log('Video ad skipped to end');
} else {
console.log('Video detected as main content, no skip');
return;
}
}
const skipButtonSelectors = [
'.ytp-ad-skip-button',
'.ytp-ad-skip-button-modern',
'.ytp-skip-ad-button',
'button.ytp-ad-skip-button',
'.ytp-ad-overlay-close-button'
];
skipButtonSelectors.forEach(selector => {
const buttons = document.querySelectorAll(selector);
buttons.forEach(button => {
if (button.offsetParent !== null) {
button.click();
console.log(`Button clicked: ${selector}`);
}
});
});
if (player.classList.contains('ad-showing') || player.classList.contains('ad-interrupting')) {
player.classList.remove('ad-showing', 'ad-interrupting');
console.log('Ad classes removed from player');
}
if (video && video.paused && isLikelyAd) {
video.play().catch(() => console.log('Error resuming after ad'));
console.log('Playback forced after ad skip');
}
}
function removeAdBanners() {
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 => {
const elements = document.querySelectorAll(selector);
elements.forEach(element => {
if (element && element.parentNode) {
element.parentNode.removeChild(element);
console.log(`In-feed/banner ad removed: ${selector}`);
}
});
});
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);
console.log('Sponsored item removed from #related');
}
});
}
function handleAds() {
try {
skipVideoAds();
removeAdBanners();
} catch (error) {
console.log('Error handling ads:', error);
}
}
function setupMutationObserver() {
const observer = new MutationObserver((mutations) => {
if (mutations.length > 50) {
console.log('Too many mutations detected, execution skipped');
return;
}
handleAds();
});
observer.observe(document.body, {
childList: true,
subtree: true,
attributes: false
});
console.log('Mutation observer enabled to detect ads');
}
window.addEventListener('load', () => {
console.log('Page loaded, starting ad management');
handleAds();
setupMutationObserver();
});
handleAds();
setInterval(() => {
handleAds();
}, 1000);
})();