From c088e9bc1ab2944b38b6aa63d22b0b9ed17c3896 Mon Sep 17 00:00:00 2001 From: swee Date: Sat, 30 Nov 2024 17:09:23 -0800 Subject: [PATCH] You wouldn't need to use a function if you only use it once. --- script.user.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/script.user.js b/script.user.js index 996a151..a03d946 100644 --- a/script.user.js +++ b/script.user.js @@ -1,5 +1,5 @@ // ==UserScript== -// @name Snap! Dark Theme +// @name DarkSnap // @namespace http://tampermonkey.net/ // @match https://snap.berkeley.edu/* // @exclude *://snap.berkeley.edu/snap/* @@ -9,14 +9,8 @@ // @description Fork of https://forum.snap.berkeley.edu/t/18272 // ==/UserScript== // -function isBootstrap5() { - // Select all elements with data-bs-theme attribute - const elementsWithTheme = document.querySelectorAll('[data-bs-theme]'); - // Check if there are any such elements - return elementsWithTheme.length > 0; -} -if (isBootstrap5()) { +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 @@ -48,4 +42,5 @@ style.innerHTML = ` color: #212529; } `; -document.head.appendChild(style); \ No newline at end of file +document.head.appendChild(style); +console.info("Loaded DarkSnap.") \ No newline at end of file