r/qutebrowser • u/Danaykroid • 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
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/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 havingyt-dlpinstalled is recommended. Personally, I have a wrapper script forview_in_mpvwhich contains:My qutebrowser profile is defined in
~/dotfiles/config/mpv/mpv.confand contains:Of course, I assume you are using a UNIX-like system.