Greasy Fork is available in English.

YouTube video/mp4

Plays video in h.264 format.

  1. // ==UserScript==
  2. // @name YouTube video/mp4
  3. // @version 1.0
  4. // @description Plays video in h.264 format.
  5. // @author gvvad
  6. // @run-at document-start
  7. // @include *.youtube.com/*
  8. // @grant none
  9. // @noframes
  10. // @license MIT; https://opensource.org/licenses/MIT
  11. // @copyright 2020, gvvad
  12. // @namespace https://greasyfork.org/users/100160
  13. // ==/UserScript==
  14.  
  15. (function () {
  16. 'use strict';
  17.  
  18. function getCustomMimeChecker(producer, isBool) {
  19. const rejector = /(webm|vp8|vp9|av01)/;
  20.  
  21. return function (mime) {
  22. if (rejector.test(mime)) {
  23. return (isBool) ? false : '';
  24. }
  25.  
  26. return producer(mime);
  27. };
  28. }
  29.  
  30. let videoElem = document.createElement('video');
  31. let v_proto = Object.getPrototypeOf(videoElem);
  32. v_proto.canPlayType = getCustomMimeChecker(v_proto.canPlayType.bind(videoElem), false);
  33. Object.setPrototypeOf(videoElem, v_proto);
  34.  
  35. if (window.MediaSource === undefined) return;
  36. window.MediaSource.isTypeSupported = getCustomMimeChecker(window.MediaSource.isTypeSupported, true);
  37. })();