Skip to content

Instantly share code, notes, and snippets.

@4v3ngR
Last active December 7, 2025 04:46
Show Gist options
  • Select an option

  • Save 4v3ngR/1a4e33ecaba02a96aa77092b7734ac97 to your computer and use it in GitHub Desktop.

Select an option

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
// ==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', () => {
setInterval(() => {
applyTheme(prefersDarkMode.matches);
if (!document.getElementById('0xdeadbeef')) {
const style = document.createElement('style');
style.setAttribute('id', '0xdeadbeef');
style.innerText = `
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 }
`;
document.head.appendChild(style);
}
}, 750);
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment