summaryrefslogtreecommitdiff
path: root/mac/.qutebrowser/greasemonkey/youtube-ads.js
blob: 21d4214d03c4f505d6cc20b9f767a689d1035687 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// ==UserScript==
// @name Skip YouTube ads
// @description Skips the ads in YouTube videos
// @run-at document-start
// @include *.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,
);