// ==UserScript== // @name GitLab Dark Theme // @namespace https://greasyfork.org/users/581142 // @include /^https?:\/{2}(?:git(?:\.(?:linux-kernel\.at|coop|fosscommunity\.in|jami\.net|oeru\.org|pleroma\.social)|lab\.(?:com|(?:gnome|haskell|trisquel)\.org|e\.foundation|freedesktop\.org)|gud\.io)|(?:code\.(?:briarproject|videolan)|0xacab|salsa\.debian|framagit|dev\.gajim)\.org||lab\.libreho\.st)\// // @grant none // @version 1.0.0 // @author brian6932 // @run-at document-start // @license MPL-2.0 // @description Forces GitLab to use it's dark mode when not logged in. // @downloadURL none // ==/UserScript== // jshint esversion: 11 // I can't do anything about the initial screen flash. const dark = () => { if (!globalThis.document.cookie.includes('gitlab_user=true')) { globalThis.Object.defineProperty(globalThis, 'gon', { __proto__: null, value: { __proto__: null } }) globalThis.Object.defineProperty(globalThis.gon, 'user_color_scheme', { __proto__: null, value: 'dark', writable: false, configurable: false }) globalThis.Object.defineProperty(globalThis.gon, 'user_color_mode', { __proto__: null, value: 'gl-system', writable: false, configurable: false }) globalThis.document.documentElement.classList.add('gl-dark') } }, event = 'beforescriptexecute' // Chromium and WebKit don't support this for some reason, and I cba to use a polyfill here. if (!globalThis.chrome || globalThis.getEventListeners?.(globalThis).hasOwnProperty(event)) globalThis.addEventListener(event, dark) else dark()