Fake HEVC support for Bilibili HDR Video

Pretend to have HEVC codec.

// ==UserScript==
// @name        Fake HEVC support for Bilibili HDR Video
// @author      Jefferson "jscher2000" Scher, Ziyuan Guo
// @namespace   bilibili-hdr
// @version     0.1
// @copyright   Copyright 2019 Jefferson Scher, Copyright 2021 Ziyuan Guo
// @license     BSD-3-Clause
// @description Pretend to have HEVC codec.
// @match       https://www.bilibili.com/video/*
// @run-at      document-start
// @grant       none
// ==/UserScript==

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 '';
    //console.log('testing for: '+ type);

    // support HEVC
    if (type.toLowerCase().indexOf('hev1') > -1 ||
        type.toLowerCase().indexOf('hvc1') > -1 ||
        type.toLowerCase().indexOf('hvt1') > -1) return true;

    // Let Firefox handle everything else
    return fallback(type);
  };
}
长期地址
遇到问题?请前往 GitHub 提 Issues,或加Q群1031348184

赞助商

Fishcpy

广告

Rainyun

注册一下就行

Rainyun

一年攒够 12 元