Youtube No Flexy Mode

Disable Flexy Mode

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Youtube No Flexy Mode
// @namespace    http://tampermonkey.net/
// @version      0.50
// @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');

    // Disables (if available) the creation of the new flexy dom.
    function disableFlexyFeature() {
        let cfg = (typeof window.ytcfg === "undefined") ? false : window.ytcfg.get("EXPERIMENT_FLAGS");
        if (!cfg || cfg.kevlar_flexy_watch_new_dom === false) return;

        cfg.kevlar_flexy_watch_new_dom = false;
        console.log('Set kevlar_flexy_watch_new_dom to false');

        cfg.kevlar_transparent_player_background = false;
        console.log('Set kevlar_transparent_player_background to false');

        window.ytcfg.set("EXPERIMENT_FLAGS", cfg);
    }

    disableFlexyFeature();
    document.addEventListener("yt-navigate-start", disableFlexyFeature, true);
})();