// ==UserScript== // @name GitLab Dark Mode When Not Logged In // @description For some reason you can't enable dark theme if you are not logged in, but with this script you can! // @version 1.0.0 // @author Pabli // @namespace https://github.com/pabli24 // @icon https://www.google.com/s2/favicons?sz=64&domain=gitlab.com // @license MIT // @match https://gitlab.com/* // @run-at document-body // @grant none // @downloadURL https://update.greasyfork.icu/scripts/522039/GitLab%20Dark%20Mode%20When%20Not%20Logged%20In.user.js // @updateURL https://update.greasyfork.icu/scripts/522039/GitLab%20Dark%20Mode%20When%20Not%20Logged%20In.meta.js // ==/UserScript== const isLight = document.documentElement.classList.contains('gl-light'); const isDark = document.documentElement.classList.contains('gl-dark'); const isNotLoggedIn = document.querySelector('header').classList.contains('header-logged-out'); if (isLight && !isDark && isNotLoggedIn) { document.documentElement.classList.replace('gl-light', 'gl-dark'); document.head.innerHTML += ''; document.head.innerHTML += ''; document.head.innerHTML += ''; const observer = new MutationObserver(mutations => { document.querySelectorAll('.white').forEach(element => { element.classList.replace('white', 'dark'); }); }); observer.observe(document.body, { childList: true, subtree: true }); }