From 014944446e3bcf88b8247dce8498de6c2dfec467 Mon Sep 17 00:00:00 2001 From: swee Date: Sat, 30 Nov 2024 17:33:38 -0800 Subject: [PATCH] We do not need to check if the page uses BS5. --- script.user.js | 50 ++++++++++++++++++++------------------------------ 1 file changed, 20 insertions(+), 30 deletions(-) diff --git a/script.user.js b/script.user.js index 5dfa6aa..16b643c 100644 --- a/script.user.js +++ b/script.user.js @@ -7,36 +7,26 @@ // @version 3 // @author Swee // @description Fork of https://forum.snap.berkeley.edu/t/18272 -// @run-at document-idle +// @run-at document-body // ==/UserScript== // -if (document.querySelectorAll('[data-bs-theme]').length > 0) { - // Set the data-bs-theme attribute to "dark" - // By doing some inspectation I determined a lot of pages use - // bootstrap 5, and this is how you make bootstrap go in dark mode - document.documentElement.setAttribute('data-bs-theme', 'dark'); - document.documentElement.classList.add("text-white"); // Make the text white with a class, rather than custom CSS. - console.info("This page uses BS5.") -} else { - // Dark mode patches for non-bootstrap pages - const noBoostrapStyle = document.createElement('style'); - noBoostrapStyle.innerHTML = ` - body { - background: #212529; - color: white; - } - .notes { - background: #2D3142 !important; - } - .trapezoid { - color: #2D3142; - } - .trapezoid-footer { - color: #212529; - } - `; - document.head.appendChild(noBoostrapStyle); - console.info("This page does NOT use BS5.") -} -document.head.appendChild(style); \ No newline at end of file +document.documentElement.setAttribute('data-bs-theme', 'dark'); +document.documentElement.classList.add("text-white"); +const noBoostrapStyle = document.createElement('style'); +noBoostrapStyle.innerHTML = ` + body { + background: #212529; + color: white; + } + .notes { + background: #2D3142 !important; + } + .trapezoid { + color: #2D3142; + } + .trapezoid-footer { + color: #212529; + } +`; +document.head.appendChild(noBoostrapStyle); \ No newline at end of file