We do not need to check if the page uses BS5.

This commit is contained in:
Nova Cat 2024-11-30 17:33:38 -08:00
parent 9cba8cf192
commit 014944446e

View file

@ -7,36 +7,26 @@
// @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) { document.documentElement.setAttribute('data-bs-theme', 'dark');
// Set the data-bs-theme attribute to "dark" document.documentElement.classList.add("text-white");
// By doing some inspectation I determined a lot of pages use const noBoostrapStyle = document.createElement('style');
// bootstrap 5, and this is how you make bootstrap go in dark mode noBoostrapStyle.innerHTML = `
document.documentElement.setAttribute('data-bs-theme', 'dark'); body {
document.documentElement.classList.add("text-white"); // Make the text white with a class, rather than custom CSS. background: #212529;
console.info("This page uses BS5.") color: white;
} else { }
// Dark mode patches for non-bootstrap pages .notes {
const noBoostrapStyle = document.createElement('style'); background: #2D3142 !important;
noBoostrapStyle.innerHTML = ` }
body { .trapezoid {
background: #212529; color: #2D3142;
color: white; }
} .trapezoid-footer {
.notes { color: #212529;
background: #2D3142 !important; }
} `;
.trapezoid { document.head.appendChild(noBoostrapStyle);
color: #2D3142;
}
.trapezoid-footer {
color: #212529;
}
`;
document.head.appendChild(noBoostrapStyle);
console.info("This page does NOT use BS5.")
}
document.head.appendChild(style);