Auto Dark Mode for Firebase Console

Works for desktop

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Auto Dark Mode for Firebase Console
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Works for desktop
// @author       Avi (https://avi12.com)
// @copyright    2025 Avi (https://avi12.com)
// @license      MIT
// @match        https://console.firebase.google.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=firebase.google.com
// @grant        none
// ==/UserScript==

(function () {
  "use strict";

  const darkQuery = matchMedia("(prefers-color-scheme: dark)");
  darkQuery.addEventListener("change", e => {
    const theme = e.matches ? "dark" : "light";
    document.body.classList.value = document.body.classList.value.replace(/fire-scheme-(light|dark)/, `fire-scheme-${theme}`);
    document.documentElement.style.colorScheme = theme;
  });

  new MutationObserver((_, observer) => {
    // noinspection CssInvalidHtmlTagReference
    const elThemeMenuToggle = document.querySelector("fire-theme-switcher");
    if (!elThemeMenuToggle) {
      return;
    }

    observer.disconnect();
    elThemeMenuToggle.click();
    const elThemeMenu = document.querySelector("#mat-menu-panel-1 > div > button:last-of-type");
    elThemeMenu.click();
  }).observe(document, {childList: true, subtree: true});
})();