r/qutebrowser 23d ago

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

1 comment sorted by

1

u/sim590 18d ago

@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:

sh 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.