mfluehr / Clean Up YouTube

// ==UserScript==
// @namespace     https://openuserjs.org/users/mfluehr
// @name          Clean Up YouTube
// @description   Remove the related video sidebar and the video wall that appears after videos.
// @license       MIT
// @version       1.0.4
// @match         *://www.youtube.com/*
// @run-at        document-start
// @grant         none
// ==/UserScript==

const params = new URLSearchParams(window.location.search);
const styleSheet = document.createElement('style');
styleSheet.type = 'text/css';

styleSheet.innerText = `
  .videowall-endscreen,
  .ytp-iv-player-content,
  .ytp-pause-overlay,
  ytd-mealbar-promo-renderer {
    display: none;
  }
`;

if (params.has('list')) {
  styleSheet.innerText += `
    #related {
      display: none;
    }
  `;
} else {
  styleSheet.innerText += `
    #secondary {
      display: none;
    }
  `;
}

document.addEventListener("DOMContentLoaded", e => {
  document.head.appendChild(styleSheet);
});