YouTube Web Tweaks lite edition

This script is based on YouTube Web Tweaks (but with minimal tweaks into it, but it also includes the VP9 disabler script that optimizes video playback well for older machines)

// ==UserScript==
// @name         YouTube Web Tweaks lite edition
// @version      1.6.1
// @description  This script is based on YouTube Web Tweaks (but with minimal tweaks into it, but it also includes the VP9 disabler script that optimizes video playback well for older machines)
// @author       Magma_Craft
// @license MIT
// @match        *://www.youtube.com/*
// @match        *://www.youtube-nocookie.com/*
// @match        *://www.youtu.be/*
// @namespace    https://greasyfork.org/en/users/933798
// @icon         https://www.youtube.com/favicon.ico
// @unwrap
// @run-at       document-start
// @unwrap
// @grant        none
// ==/UserScript==

(function() {
let css = `
/* Remove filter categories on search results and playlists to make the UI less usable on low-entry machines */
ytd-item-section-renderer.style-scope.ytd-section-list-renderer[page-subtype="playlist"] > #header.ytd-item-section-renderer > ytd-feed-filter-chip-bar-renderer {
display: none !important;
}
 
div#chip-bar.style-scope.ytd-search-header-renderer > yt-chip-cloud-renderer.style-scope.ytd-search-header-renderer > div#container.style-scope.yt-chip-cloud-renderer {
display: none !important;
}
 
/* Remove minimal annoyances */
ytd-ad-slot-renderer, div#sparkles-container.style-scope.ytd-promoted-sparkles-web-renderer, ytm-promoted-sparkles-web-renderer, ytd-video-quality-promo-renderer, ytd-merch-shelf-renderer, ytd-enforcement-message-view-model, div[is-shared-heimdall], tp-yt-iron-overlay-backdrop.opened, ytd-promoted-sparkles-web-renderer, ytd-text-image-no-button-layout-renderer, #cinematics.ytd-watch-flexy {
display: none !important
}

/* Remove every related list view except ytd-compact-video render and limit the number of yt-lockup-view-model */
#related ytd-compact-playlist-renderer, #related ytd-compact-radio-renderer, #related ytd-compact-movie-renderer, #related yt-lockup-view-model, #related ytd-channel-renderer, #related ytd-continuation-item-renderer, #related #continuations {
display: none !important
}

#related yt-lockup-view-model:nth-of-type(1), #related yt-lockup-view-model:nth-of-type(2), #related yt-lockup-view-model:nth-of-type(3), #related yt-lockup-view-model:nth-of-type(4), #related yt-lockup-view-model:nth-of-type(5), #related yt-lockup-view-model:nth-of-type(6), #secondary #related yt-lockup-view-model:nth-of-type(7), #secondary #related yt-lockup-view-model:nth-of-type(8), #secondary #related yt-lockup-view-model:nth-of-type(9), #secondary #related yt-lockup-view-model:nth-of-type(10) {
display: flex !important
}

/* More tweaks to the UI (this was meant for older browsers without uBlock Origin) */
#secondary.ytd-watch-grid {
width: 402px !important;
min-width: 300px !important
}

ytd-watch-flexy[default-layout][reduced-top-margin] #primary.ytd-watch-flexy, ytd-watch-flexy[default-layout][reduced-top-margin] #secondary.ytd-watch-flexy {
padding-top: var(--ytd-margin-6x) !important
}

ytd-watch-metadata[title-headline-xs] h1.ytd-watch-metadata, ytd-watch-metadata[title-headline-m] h1.ytd-watch-metadata {
font-size: 2rem !important;
line-height: 2.8rem !important
}

ytd-search ytd-video-renderer, ytd-search ytd-channel-renderer, ytd-search ytd-playlist-renderer, ytd-search ytd-radio-renderer, ytd-search ytd-movie-renderer, ytd-video-renderer.style-scope.ytd-item-section-renderer, ytd-playlist-renderer.style-scope.ytd-item-section-renderer, ytd-search .lockup.ytd-item-section-renderer {
margin-top: 16px !important
}

ytd-compact-video-renderer.style-scope.ytd-item-section-renderer, #related .lockup.ytd-item-section-renderer {
margin-top: 8px !important
}`;
if (typeof GM_addStyle !== "undefined") {
  GM_addStyle(css);
} else {
  let styleNode = document.createElement("style");
  styleNode.appendChild(document.createTextNode(css));
  (document.querySelector("head") || document.documentElement).appendChild(styleNode);
}
})();

var mse = window.MediaSource;
if (mse){
  // Set up replacement for MediaSource type support function
  var nativeITS = mse.isTypeSupported.bind(mse);
  mse.isTypeSupported = ourITS(nativeITS);
}
// Here's the replacement
function ourITS(fallback){
  // type is a string (hopefully!) sent by the page
  return function (type) {
    if (type === undefined) return '';
    // We only reject VP9
    if (type.toLowerCase().indexOf('vp9') > -1) return '';
    if (type.toLowerCase().indexOf('vp09') > -1) return ''; // Added 12/20/2019
    // Let Firefox handle everything else
    return fallback(type);
  };
}
 
//
// What is this userscript trying to address?
// When playing a video, only a small part of the video loads, and the subsequent
// parts do not load afterward.

(function () {
  "use strict";

  const originalGetContext = HTMLCanvasElement.prototype.getContext;
  HTMLCanvasElement.prototype.getContext = function (contextType) {
    if (contextType === "webgl" || contextType === "webgl2") {
      console.log("WebGL is disabled by Tampermonkey");
      return null;
    }
    return originalGetContext.apply(this, arguments);
  };
})();