We do not need to check if the page uses BS5.
This commit is contained in:
parent
9cba8cf192
commit
014944446e
1 changed files with 20 additions and 30 deletions
|
@ -7,19 +7,12 @@
|
||||||
// @version 3
|
// @version 3
|
||||||
// @author Swee
|
// @author Swee
|
||||||
// @description Fork of https://forum.snap.berkeley.edu/t/18272
|
// @description Fork of https://forum.snap.berkeley.edu/t/18272
|
||||||
// @run-at document-idle
|
// @run-at document-body
|
||||||
// ==/UserScript==
|
// ==/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.setAttribute('data-bs-theme', 'dark');
|
||||||
document.documentElement.classList.add("text-white"); // Make the text white with a class, rather than custom CSS.
|
document.documentElement.classList.add("text-white");
|
||||||
console.info("This page uses BS5.")
|
|
||||||
} else {
|
|
||||||
// Dark mode patches for non-bootstrap pages
|
|
||||||
const noBoostrapStyle = document.createElement('style');
|
const noBoostrapStyle = document.createElement('style');
|
||||||
noBoostrapStyle.innerHTML = `
|
noBoostrapStyle.innerHTML = `
|
||||||
body {
|
body {
|
||||||
|
@ -37,6 +30,3 @@ if (document.querySelectorAll('[data-bs-theme]').length > 0) {
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
document.head.appendChild(noBoostrapStyle);
|
document.head.appendChild(noBoostrapStyle);
|
||||||
console.info("This page does NOT use BS5.")
|
|
||||||
}
|
|
||||||
document.head.appendChild(style);
|
|
Loading…
Reference in a new issue