Youtube No Flexy Mode

Disable Flexy Mode

当前为 2018-05-23 提交的版本,查看 最新版本

// ==UserScript==
// @name         Youtube No Flexy Mode
// @namespace    http://tampermonkey.net/
// @version      0.40
// @description  Disable Flexy Mode
// @author       Botan
// @match        *://*.youtube.com/*
// @grant        none
// @run-at       document-end
// ==/UserScript==


// Thanks to AlexT. this fix does not longer use any intervals, it instead uses the Youtube API directly.
(function() {
    'use strict';
     if (window.top != window.self) return;
     console.log('Youtube No Flexy Mode');


    var ytPlayer;
    // Sets the player background to black. Otherwise the background might be transparent.
    function setBackground () {
        ytPlayer = document.getElementById("movie_player") || document.getElementsByClassName("html5-video-player")[0];
        if (ytPlayer) {
            if(ytPlayer.style.background!=='rgb(0, 0, 0)')
            {
                ytPlayer.style.background='#000000';
                console.log('Set player background color to black!');
            }
        }
    }

    // Disables (if available) the creation of the new flexy dom.
    function ytNoFlexy() {
        if (typeof window.yt === "undefined" || window.yt.config_.EXPERIMENT_FLAGS.kevlar_flexy_watch_new_dom === false)
        {
            return;
        } else {
            window.yt.config_.EXPERIMENT_FLAGS.kevlar_flexy_watch_new_dom = false;
			console.log('Flexy disabled!');
        }
    }
    ytNoFlexy();
	setBackground();

	document.addEventListener("yt-navigate-start", ytNoFlexy, true);
	document.addEventListener("yt-navigate-finish", setBackground, true);
})();