// ==UserScript== // @name Super Duolingo Ad Blocker // @version 0.1 // @description Block ads and unwanted promotional content on Duolingo, including full-browser videos and dynamically named ad classes. // @author Zinovia // @match https://www.duolingo.com/* // @grant none // @namespace https://greasyfork.org/users/1340999 // @downloadURL none // ==/UserScript== (function() { 'use strict'; // Function to inject CSS into the document function addStyles(css) { const style = document.createElement('style'); style.type = 'text/css'; style.textContent = css; document.head.appendChild(style); } // CSS to hide specific promotional and ad content const styles = ` /* General video ad elements */ video._48lxa, video { display: none !important; volume: 0; } /* Specific divs associated with ads and promotions */ div[data-test="purchase-step-active"], div._3D_HB, div._16rRh, div._1tzFd, div._3wtIn.Vm8C0._2zxQ8, div._2CoFd, .SEnGu, ._3rxfc, ._1-uth, ._3U6Po { display: none !important; } `; // Inject styles into the document addStyles(styles); // Function to dynamically hide elements and mute videos function hideElementsAndMuteVideos() { const selectors = [ 'video._48lxa', 'div[data-test="purchase-step-active"]', 'div._3D_HB', 'div._16rRh', 'div._1tzFd', 'div._3wtIn.Vm8C0._2zxQ8', 'div._2CoFd', '.SEnGu', '._3rxfc', '._1-uth', '._3U6Po' ]; selectors.forEach(selector => { document.querySelectorAll(selector).forEach(element => { element.style.display = 'none'; }); }); // Mute and pause videos to prevent audio play document.querySelectorAll('video').forEach(video => { video.volume = 0; video.pause(); }); } // Run function initially to hide elements and mute videos hideElementsAndMuteVideos(); // Observe DOM changes and apply modifications as necessary const observer = new MutationObserver(hideElementsAndMuteVideos); observer.observe(document.body, { childList: true, subtree: true }); console.log('Super Duolingo Ad Blocker initialized.'); })();