Google Classroom Dark Mode

Enables dark mode for Google Classroom.

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Google Classroom Dark Mode
// @description  Enables dark mode for Google Classroom.
// @version      1.0
// @icon         https://www.google.com/favicon.ico
// @author       blank
// @namespace    https://google.com
// @match        https://classroom.google.com/*
// @run-at       document-start
// @license      MIT
// ==/UserScript==
(function() {
    "use strict";
 
    const log = console.log;
 
    // Get the dark mode setting.
    const darkModeSetting = localStorage.getItem("darkMode");
 
    // If the dark mode setting is enabled, set the dark mode property of the document to true.
    if (darkModeSetting === "true") {
        document.documentElement.classList.add("dark");
    }
 
    // Listen for the change event on the dark mode setting.
    document.querySelector("#darkMode").addEventListener("change", () => {
 
        // Get the new value of the dark mode setting.
        const newDarkModeSetting = document.querySelector("#darkMode").checked;
 
        // Set the dark mode property of the document to the new value.
        document.documentElement.classList.toggle("dark", newDarkModeSetting);
 
        // Save the new value of the dark mode setting.
        localStorage.setItem("darkMode", newDarkModeSetting);
    });
})();