Hide VP9 support from YouTube

Hide VP9 support for Firefox. v0.2 2019-12-20

  1. // ==UserScript==
  2. // @name Hide VP9 support from YouTube
  3. // @author Jefferson "jscher2000" Scher
  4. // @namespace JeffersonScher
  5. // @version 0.2
  6. // @copyright Copyright 2019 Jefferson Scher
  7. // @license BSD-3-Clause
  8. // @description Hide VP9 support for Firefox. v0.2 2019-12-20
  9. // @match https://www.youtube.com/*
  10. // @match https://www.youtube-nocookie.com/*
  11. // @match https://www.youtu.be/*
  12. // @run-at document-start
  13. // @grant none
  14. // ==/UserScript==
  15.  
  16. // Modified from https://github.com/erkserkserks/h264ify/tree/master/src/inject as of 2018-05-16 (MIT license)
  17.  
  18. var mse = window.MediaSource;
  19. if (mse){
  20. // Set up replacement for MediaSource type support function
  21. var nativeITS = mse.isTypeSupported.bind(mse);
  22. mse.isTypeSupported = ourITS(nativeITS);
  23. }
  24. // Here's the replacement
  25. function ourITS(fallback){
  26. // type is a string (hopefully!) sent by the page
  27. return function (type) {
  28. if (type === undefined) return '';
  29. // We only reject VP9
  30. if (type.toLowerCase().indexOf('vp9') > -1) return '';
  31. if (type.toLowerCase().indexOf('vp09') > -1) return ''; // Added 12/20/2019
  32. // Let Firefox handle everything else
  33. return fallback(type);
  34. };
  35. }