Youtube Material and Dark

Makes Youtube the new hidden material and dark mode. Warning buggy! Created by @xIGBClutchIx

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        Youtube Material and Dark
// @version     1.0.4
// @description Makes Youtube the new hidden material and dark mode. Warning buggy! Created by @xIGBClutchIx
// @match       http*://www.youtube.com/*
// @require     http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
// @grant       none
// @run-at      document-start
// @namespace   https://greasyfork.org/en/scripts/26550-youtube-material-and-dark
// ==/UserScript==

var loaded = function() {
    // Set cookie
    document.cookie="PREF=f6=7;path=/;domain=.youtube.com";
    // Enable dark
    setTimeout(function(){
        enableDark();
    }, 200);
};

if (document.readyState == 'complete') {
    loaded();
} else {
    window.addEventListener('DOMContentLoaded', loaded);
}

function enableDark() {
    // Add debug menu temp
    $("#extra-buttons").html("<ytd-debug-menu data='[[debugData_]]'></ytd-debug-menu>" + $("#extra-buttons").html());
    // Debug menu set dark
    document.querySelector("ytd-debug-menu").fire("yt-dark-mode-toggled", {
        enabled: true
    });
    // Hack way to fix non dark header
    $(".ytd-masthead-1").css("background", "rgb(51,51,51)", "important");
    // Remove all nonsense
    setTimeout(function(){
        $("#extra-buttons").css("display", "none");
    }, 200);
}