// ==UserScript== // @name YouTube H.264 (h264ify) // @name:ru YouTube H.264 (h264ify) // @namespace https://www.youtube.com // @version 18112023.2 // @description https://github.com/erkserkserks/h264ify // @description:ru https://github.com/erkserkserks/h264ify // @match *://*.youtube.com/* // @match *://*.youtube-nocookie.com/* // @match *://*.youtubekids.com/* // @license MIT // @grant none // @run-at document-start // @downloadURL none // ==/UserScript== const block60fps = true; function modifyVideoTypeChecker() { const videoElement = document.createElement('video'); const originalCanPlayType = videoElement.canPlayType.bind(videoElement); Object.setPrototypeOf(videoElement, { canPlayType: makeModifiedTypeChecker(originalCanPlayType) }); const mediaSource = window.MediaSource; if (mediaSource === undefined) return; const originalIsTypeSupported = mediaSource.isTypeSupported.bind(mediaSource); mediaSource.isTypeSupported = makeModifiedTypeChecker(originalIsTypeSupported); } const makeModifiedTypeChecker = (originalChecker) => (type) => { if (typeof type !== 'string') return ''; const disallowedTypes = ['webm', 'vp8', 'vp9', 'av01']; for (const disallowedType of disallowedTypes) { if (type.includes(disallowedType)) return ''; } if (block60fps) { const match = /framerate=(\d+)/.exec(type); if (match && match[1] > 30) return ''; } return typeof originalChecker === 'function' ? originalChecker(type) : ''; }; modifyVideoTypeChecker();