Greasy Fork is available in English.
https://github.com/erkserkserks/h264ify
当前为
// ==UserScript==
// @name YouTube H.264 (h264ify)
// @name:ru YouTube H.264 (h264ify)
// @namespace https://www.youtube.com
// @version 18112023.1
// @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
// ==/UserScript==
// false or true for 30fps
let block60fps = true;
function h264ify() {
// Override video element canPlayType() function
var videoElem = document.createElement('video');
var origCanPlayType = videoElem.canPlayType.bind(videoElem);
videoElem.__proto__.canPlayType = makeModifiedTypeChecker(origCanPlayType);
// Override media source extension isTypeSupported() function
var mse = window.MediaSource;
// Check for MSE support before use
if (mse === undefined) return;
var origIsTypeSupported = mse.isTypeSupported.bind(mse);
mse.isTypeSupported = makeModifiedTypeChecker(origIsTypeSupported);
}
// return a custom MIME type checker that can defer to the original function
function makeModifiedTypeChecker(origChecker) {
// Check if a video type is allowed
return function (type) {
if (type === undefined) return '';
var disallowed_types = ['webm', 'vp8', 'vp9', 'av01'];
// If video type is in disallowed_types, say we don't support them
for (var i = 0; i < disallowed_types.length; i++) {
if (type.indexOf(disallowed_types[i]) !== -1) return '';
}
if (block60fps) {
var match = /framerate=(\d+)/.exec(type);
if (match && match[1] > 30) return '';
}
// Otherwise, ask the browser
return origChecker(type);
};
}
h264ify();