// ==UserScript== // @name FuckAds - A Youtube pub skipper // @namespace http://tampermonkey.net/ // @version 3.2 // @description Automatically hide and skips YouTube ads and mutes/unmutes video on Firefox (quickly tested) and Opera (extensively tested). Doesn't seems to work as expected on Google Chrome. // @author John Doe // @match *://www.youtube.com/* // @grant none // @license MIT // @downloadURL none // ==/UserScript== (function () { console.log('fuckads') let adSkipped const messageDiv = document.createElement('div') if (location.href.includes('/watch')) { console.log('URL includes /watch') adSkipped = false skipAd() } function createMessage () { messageDiv.id = 'ad-skip-message' messageDiv.style.cssText = 'position: fixed; bottom: 50%; left: 50%; background: red; color: white; padding: 5px; z-index: 999;' messageDiv.textContent = 'Ad muted and hidden by FuckAds, will be skipped ASAP if possible, if not you just need to wait. Keep your mind ad-free.' document.body.appendChild(messageDiv) } function skipAd () { if (adSkipped === false) { const player = document.getElementById('movie_player') const skipButton = document.querySelector('.ytp-ad-skip-button-text') if (player && skipButton) { skipButton.click() console.log('Ad skipped') } adSkipped = true messageDiv.style.zIndex = '-999' player.unMute() player.style.zIndex = '999' player.seekTo(0) player.playVideo() } } function startObserving () { const player = document.getElementById('movie_player') if (player && player.classList.contains('ad-showing')) { createMessage() player.mute() player.style.zIndex = '-999' skipAd() } } startObserving() function checkUrlChange () { if (location.href.includes('/watch')) { adSkipped = false startObserving() } } setInterval(checkUrlChange, 1000) // Continuously check for URL change })()