Remove YouTube End Cards

Removes YouTube end cards from videos automatically.

  1. // ==UserScript==
  2. // @name Remove YouTube End Cards
  3. // @namespace https://tampermonkey.net/
  4. // @version 1.1
  5. // @description Removes YouTube end cards from videos automatically.
  6. // @author wasivis
  7. // @match https://www.youtube.com/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com
  9. // @license MIT
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function () {
  14. 'use strict';
  15.  
  16. const END_CARD_SELECTOR = '.ytp-ce-element';
  17.  
  18. function removeEndCards() {
  19. const endCards = document.querySelectorAll(END_CARD_SELECTOR);
  20. endCards.forEach(card => card.remove());
  21. }
  22.  
  23. const observer = new MutationObserver(() => {
  24. removeEndCards();
  25. });
  26.  
  27. observer.observe(document.body, {
  28. childList: true,
  29. subtree: true
  30. });
  31.  
  32. removeEndCards();
  33. })();