Hide HDR support from YouTube

Hide HDR support for Firefox 69. v0.1 2019-10-10

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name        Hide HDR support from YouTube
// @author      Jefferson "jscher2000" Scher
// @namespace   JeffersonScher
// @version     0.1
// @copyright   Copyright 2019 Jefferson Scher
// @license     BSD-3-Clause
// @description Hide HDR support for Firefox 69. v0.1 2019-10-10
// @match       https://www.youtube.com/*
// @match       https://www.youtube-nocookie.com/*
// @match       https://www.youtu.be/*
// @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);

    // Don't support HDR (current as of 10/10/2019)
    if (type.toLowerCase().indexOf('eotf=bt709') > -1 ||
        type.toLowerCase().indexOf('eotf=catavision') > -1) return '';

    // Uncomment to block all VP9 (if performance is bad)
    //if (type.toLowerCase().indexOf('vp9') > -1) return '';

    // Let Firefox handle everything else
    return fallback(type);
  };
}