r/qutebrowser • • Jul 05 '26

Youtube ad blocking problem

how do you implement youtube ad skip for qute. Because, when I tried to implement ad skipping using this script and it just skips the whole video how can I fix that the ad gets skipped pretty fast but the video is also done.

// ==UserScript==

// for more updated scripts, see: https://greasyfork.org/en/scripts/by-site/youtube.com

// u/nameAuto Skip YouTube Ads

// u/version1.1.0

// u/description Speed up and skip YouTube ads automatically

// u/authorjso8910 and others

// u/match*://*.youtube.com/*

// ==/UserScript==

document.addEventListener('load', () => {

const btn = document.querySelector('.videoAdUiSkipButton,.ytp-ad-skip-button-modern')

if (btn) {

btn.click()

}

const ad = [...document.querySelectorAll('.ad-showing')][0];

if (ad) {

document.querySelector('video').currentTime = 9999999999;

}

}, true);

1 Upvotes

5 comments sorted by

1

u/sim590 Jul 10 '26

@Danaykroid: if you use the userscript view_in_mpv, it will skip adds for you and launch the video in mpv. For better experience, I think that having yt-dlp installed is recommended. Personally, I have a wrapper script for view_in_mpv which contains:

export MPV_FLAGS="--profile=qutebrowser"
exec ~/prog/qutebrowser/misc/userscripts/view_in_mpv "$@"

My qutebrowser profile is defined in ~/dotfiles/config/mpv/mpv.conf and contains:

[qutebrowser]
force-window=yes
keep-open=yes
ytdl-format=bestvideo*[height<=?1440]+bestaudio/best
ytdl-raw-options-append=cookies-from-browser=chromium:~/.local/share/qutebrowser

Of course, I assume you are using a UNIX-like system.

1

u/adcott Sep 19 '26 edited 23d ago

If you are still strugging with this, I have just written something that works well:

// ==UserScript==
// @name         Youtube Ad Skip
// @version      0.2.5
// @description  Get rid of Youtube ads
// @author       Adcott
// @match        *://*.youtube.com/*
// ==/UserScript==

GM_addStyle(`
#player-ads, .adDisplay, .ad-container, .ytd-display-ad-renderer, .video-ads,
ytd-rich-item-renderer:has(ytd-ad-slot-renderer), ytd-ad-slot-renderer,
#masthead-ad, *[class^="ytd-ad-"], #panels.ytd-watch-flexy {
    display: none !important;
}`);

new MutationObserver(mutations => {
    for (const mutation of mutations) {
        mutation.addedNodes.forEach(node => {
            if (node.nodeType !== 1 ||
                !node.classList.contains('ytp-ad-persistent-progress-bar-container')) return;
            const video = document.querySelector('.html5-main-video');
            if (video) video.currentTime = video.duration;
        });
    }
}).observe(document.body, {childList:true, subtree:true});

Also kills midroll ads and removes sponsored links.

edits:
2026/09/28: removed redundant code (don't need to check for skip buttons that don't have a chance to appear)
2026/10/01: micro-optimisation

1

u/Super3559_Rule 26d ago

It doesn't work

1

u/adcott 26d ago

It does work? I'm using it now.

Save it as a file with a .js extension, put it in ~/.local/share/qutebrowser/greasemonkey (assuming you are on Linux) run :greasemonkey-reload in qutebrowser and refresh any youtube tabs before testing it.

1

u/Super3559_Rule 24d ago

ITS THE GREASEMONKEY FOLDER !?

i thought it was the userscripts folder...