You wouldn't need to use a function if you only use it once.
This commit is contained in:
parent
2dc616f787
commit
c088e9bc1a
1 changed files with 4 additions and 9 deletions
|
@ -1,5 +1,5 @@
|
||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name Snap! Dark Theme
|
// @name DarkSnap
|
||||||
// @namespace http://tampermonkey.net/
|
// @namespace http://tampermonkey.net/
|
||||||
// @match https://snap.berkeley.edu/*
|
// @match https://snap.berkeley.edu/*
|
||||||
// @exclude *://snap.berkeley.edu/snap/*
|
// @exclude *://snap.berkeley.edu/snap/*
|
||||||
|
@ -9,14 +9,8 @@
|
||||||
// @description Fork of https://forum.snap.berkeley.edu/t/18272
|
// @description Fork of https://forum.snap.berkeley.edu/t/18272
|
||||||
// ==/UserScript==
|
// ==/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"
|
// Set the data-bs-theme attribute to "dark"
|
||||||
// By doing some inspectation I determined a lot of pages use
|
// By doing some inspectation I determined a lot of pages use
|
||||||
// bootstrap 5, and this is how you make bootstrap go in dark mode
|
// bootstrap 5, and this is how you make bootstrap go in dark mode
|
||||||
|
@ -49,3 +43,4 @@ style.innerHTML = `
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
document.head.appendChild(style);
|
document.head.appendChild(style);
|
||||||
|
console.info("Loaded DarkSnap.")
|
Loading…
Reference in a new issue