Last active
December 9, 2025 04:30
-
-
Save 4v3ngR/1a4e33ecaba02a96aa77092b7734ac97 to your computer and use it in GitHub Desktop.
An automatic dark/light theme switcher and layout improvement for the gab.com website
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name Automatic gab theme switcher | |
| // @namespace http://tampermonkey.net/ | |
| // @version 2025-12-06 | |
| // @description Automatically switch between dark and light themese | |
| // @author 4v3ngR | |
| // @match https://gab.com/* | |
| // @icon https://www.google.com/s2/favicons?sz=64&domain=gab.com | |
| // @grant none | |
| // @run-at document-start | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| const prefersDarkMode = window.matchMedia("(prefers-color-scheme: dark)"); | |
| const applyTheme = (isDark) => { | |
| const html = document.querySelector('html'); | |
| if (html) { | |
| html.setAttribute('theme', isDark ? 'muted' : 'light'); | |
| html.setAttribute('data-theme', isDark ? 'dark' : 'light'); | |
| } | |
| } | |
| prefersDarkMode.addEventListener("change", (e) => { | |
| applyTheme(e.matches); | |
| }); | |
| window.addEventListener('load', () => { | |
| const doit = () => { | |
| applyTheme(prefersDarkMode.matches); | |
| if (!document.getElementById('0xdeadbeef')) { | |
| const style = document.createElement('style'); | |
| style.setAttribute('id', '0xdeadbeef'); | |
| style.innerHTML = ` | |
| main { flex-grow: 2 !important; max-width: 100% !important; } | |
| main[class="relative"] { justify-content: space-between !important; } | |
| main[class="relative"] > div { flex-grow: 999 !important; padding: 0px !important; margin: 0px !important; justify-content: space-between; min-width: 100% !important; } | |
| aside { flex-grow: 0 !important; flex-shrink: 1 !important; max-width: 220px !important; } | |
| .backdrop-blur-sm { backdrop-filter: none; !important; -webkit--backdrop-filter: none !important; } | |
| `; | |
| document.body.appendChild(style); | |
| } | |
| } | |
| setInterval(() => { | |
| doit(); | |
| }, 1000); | |
| doit(); | |
| }); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment