// ==UserScript== // @name Twitch Ad Blocker // @namespace http://tampermonkey.net/ // @version 1.0 // @description Block Twitch ads // @author Your Name // @match https://www.twitch.tv/* // @grant none // ==/UserScript== (function() { 'use strict'; // Remove Twitch ads function removeTwitchAds() { // Remove the main ad container const adContainer = document.querySelector('.video-player__ad-container'); if (adContainer) { adContainer.remove(); } // Remove individual ads (pre-roll, mid-roll, etc.) const ads = document.querySelectorAll('.player-ad-overlay'); for (const ad of ads) { ad.remove(); } } // Watch for changes to the DOM and remove ads in real time const observer = new MutationObserver(mutations => { for (const mutation of mutations) { const addedNodes = mutation.addedNodes; for (const node of addedNodes) { if (node.nodeName === 'DIV' && node.classList.contains('video-player__ad-container')) { requestAnimationFrame(removeTwitchAds); } } } }); // Start observing the body for changes const body = document.querySelector('body'); observer.observe(body, { childList: true, subtree: true }); // Wait for the player to be ready before removing ads function waitForPlayer() { const player = document.querySelector('.video-player__container'); if (player) { player.addEventListener('play', removeTwitchAds); } else { setTimeout(waitForPlayer, 500); } } waitForPlayer(); })(); s