// ==UserScript==
// @name Bloqueador de Anúncios para YouTube/YouTube Music
// @namespace http://tampermonkey.net/
// @version 2.3
// @description Bloqueador avançado de anúncios para YouTube e YouTube Music
// @author _PeDeCoca
// @match *://*.youtube.com/*
// @match *://*.youtube-nocookie.com/*
// @match *://*.music.youtube.com/*
// @grant GM_addStyle
// @grant unsafeWindow
// @grant GM_xmlhttpRequest
// @run-at document-start
// @license @Mit
// ==/UserScript==
(function() {
'use strict';
// Estilos do ícone com emoji
const iconStyles = `
#adblock-indicator {
position: fixed;
top: 10px;
right: 10px;
width: 40px;
height: 40px;
cursor: pointer;
z-index: 9999999;
display: flex;
align-items: center;
justify-content: center;
font-size: 25px;
background: white;
border-radius: 50%;
transition: all 0.3s ease;
}
#adblock-indicator::before {
content: '🛡️';
position: relative;
z-index: 2;
}
#adblock-indicator::after {
content: '';
position: absolute;
inset: -3px;
background: conic-gradient(
from 0deg,
#ff0000,
#ff7300,
#fffb00,
#48ff00,
#00ffd5,
#002bff,
#7a00ff,
#ff00c8,
#ff0000
);
border-radius: 50%;
z-index: 0;
animation: rotate 3s linear infinite, glow 2s ease-in-out infinite alternate;
opacity: 0.8;
}
#adblock-indicator:hover {
transform: scale(1.1);
}
#adblock-indicator:hover::after {
animation: rotate 1s linear infinite, glow 1s ease-in-out infinite alternate;
opacity: 1;
}
@keyframes rotate {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
@keyframes glow {
0% {
filter: hue-rotate(0deg) brightness(1) blur(2px);
transform: rotate(0deg) scale(1);
}
100% {
filter: hue-rotate(360deg) brightness(1.2) blur(3px);
transform: rotate(360deg) scale(1.05);
}
}
`;
// Estilos para bloqueio agressivo de anúncios
const aggressiveAdStyles = `
.video-ads,
.ytp-ad-overlay-slot,
#masthead-ad,
#player-ads,
ytd-promoted-video-renderer,
.ytd-promoted-sparkles-web-renderer,
.ytd-display-ad-renderer,
.ytd-in-feed-ad-layout-renderer,
ytd-compact-promoted-video-renderer,
.ytd-promoted-video-descriptor-renderer,
/* Additional aggressive selectors */
ytd-ad-slot-renderer,
ytd-in-feed-ad-layout-renderer,
ytd-banner-promo-renderer,
ytd-statement-banner-renderer,
ytd-video-masthead-ad-advertiser-info-renderer,
ytd-engagement-panel-section-list-renderer[target-id="engagement-panel-ads"],
.ytd-advertisement-renderer,
.ytp-ad-overlay-image,
.ytp-ad-text-overlay,
#offer-module,
#premium-upsell,
.ytd-banner-promo-renderer-background,
paper-dialog.ytd-popup-container,
.ytd-video-quality-promo-renderer,
.ytd-mealbar-promo-renderer,
#masthead-ad-container,
/* Seletores do Google AdSense */
ins.adsbygoogle,
.adsbygoogle,
iframe[src*="adsbygoogle"] {
display: none !important;
opacity: 0 !important;
pointer-events: none !important;
width: 0 !important;
height: 0 !important;
position: fixed !important;
top: -1000px !important;
left: -1000px !important;
}
`;
// Adiciona ambos os estilos
GM_addStyle(iconStyles + aggressiveAdStyles);
// Adiciona elemento indicador
const addIndicator = () => {
const indicator = document.createElement('div');
indicator.id = 'adblock-indicator';
indicator.title = 'AdBlock Ativado - Clique para entrar em contato discord: _PeDeCoca';
indicator.addEventListener('click', () => {
window.open('https://discord.com/users/_PeDeCoca', '_blank');
});
document.body.appendChild(indicator);
};
// Bloqueador avançado de anúncios
const ultraBlocker = {
init() {
addIndicator();
this.injectAntiAdBlockKiller();
this.setupAggressiveSkipper();
this.hijackXHR();
this.bypassPremiumChecks();
this.setupObserver();
},
setupAggressiveSkipper() {
setInterval(() => {
const video = document.querySelector('video');
if (video) {
// Força o pulo de qualquer conteúdo publicitário
if (document.querySelector('.ad-showing')) {
video.currentTime = video.duration;
video.playbackRate = 16;
this.clickSkipBtn();
}
// Remove anúncios sobrepostos
this.removeAdElements();
}
}, 50);
},
// Função para clicar no botão de pular
clickSkipBtn() {
const skipBtns = [
'.ytp-ad-skip-button',
'.videoAdUiSkipButton',
'.ytp-ad-skip-button-modern'
];
skipBtns.forEach(btn => {
const skipButton = document.querySelector(btn);
if (skipButton) skipButton.click();
});
},
// Injeta o anti-detector de bloqueador
injectAntiAdBlockKiller() {
const code = function() {
const _toString = Function.toString;
Function.prototype.toString = function() {
if (this === Function.prototype.toString) return _toString.call(this);
if (this.name === 'detect') return 'function detect() { return false; }';
if (this.name === 'isAdBlocker') return 'function isAdBlocker() { return false; }';
return _toString.call(this);
};
// Sobrescreve propriedades de detecção de anúncios
Object.defineProperties(window, {
'adBlocker': { value: false },
'google_ad_status': { value: 1 },
'ytInitialPlayerResponse': {
get: function() {
return {
adPlacements: [],
playerAds: [],
adSlots: [],
videoDetails: {
isLiveContent: false
}
};
}
}
});
}.toString();
// Usa método de injeção mais seguro
const script = document.createElement('script');
script.textContent = `(${code})();`;
const container = document.head || document.documentElement;
container.addEventListener('load', function() {
this.remove();
}, { once: true });
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', () => container.appendChild(script));
} else {
container.appendChild(script);
}
},
// Intercepta requisições XHR
hijackXHR() {
const XHR = XMLHttpRequest.prototype;
const open = XHR.open;
const send = XHR.send;
XHR.open = function(method, url) {
if (url.includes('/api/stats/')) {
arguments[1] = 'about:blank';
}
return open.apply(this, arguments);
};
XHR.send = function(data) {
if (this.responseType === 'json' && data?.includes('adPlacements')) {
return;
}
return send.apply(this, arguments);
};
},
// Bypass nas verificações de conta Premium
bypassPremiumChecks() {
Object.defineProperty(window, 'ytplayer', {
get: () => ({
config: {
loaded: true,
args: {
raw_player_response: {
adPlacements: [],
videoDetails: {
isPrivate: false,
isLive: false,
isLowLatencyLiveStream: false,
isUpcoming: false
}
}
}
}
})
});
},
// Configura observador de mudanças no DOM
setupObserver() {
const observer = new MutationObserver(() => {
const adElements = document.querySelectorAll([
'ytd-promoted-video-renderer',
'ytd-display-ad-renderer',
'ytd-compact-promoted-video-renderer',
'.ytd-promoted-sparkles-web-renderer',
'ins.adsbygoogle',
'.adsbygoogle',
'iframe[src*="adsbygoogle"]'
].join(','));
adElements.forEach(ad => ad.remove());
});
observer.observe(document.body, {
childList: true,
subtree: true
});
}
};
// Inicializa o bloqueador avançado
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', () => ultraBlocker.init());
} else {
ultraBlocker.init();
}
// Bloqueio avançado de requisições com mais padrões
const originalFetch = unsafeWindow.fetch;
unsafeWindow.fetch = async function(...args) {
const url = args[0]?.url || args[0];
if (typeof url === 'string' && (
url.includes('doubleclick.net') ||
url.includes('googlesyndication.com') ||
url.includes('/pagead/') ||
url.includes('google-analytics.com') ||
url.includes('youtube.com/api/stats/ads') ||
url.includes('youtube.com/pagead/') ||
url.includes('youtube.com/get_midroll_') ||
url.includes('youtube.com/ptracking') ||
url.includes('youtube.com/annotations_invideo') ||
url.includes('youtube.com/api/stats/watchtime')
)) {
return new Response(JSON.stringify({
playerResponse: {
adPlacements: [],
playbackTracking: {},
videoDetails: {
isLiveContent: false
}
}
}));
}
return originalFetch.apply(this, args);
};
})();