darkSnap/script.user.js

42 lines
1.3 KiB
JavaScript
Raw Normal View History

2024-11-30 17:00:33 -08:00
// ==UserScript==
// @name DarkSnap
2024-11-30 17:03:10 -08:00
// @namespace http://tampermonkey.net/
2024-11-30 17:00:33 -08:00
// @match https://snap.berkeley.edu/*
2024-11-30 17:03:10 -08:00
// @exclude *://snap.berkeley.edu/snap/*
2024-11-30 17:00:33 -08:00
// @grant none
// @version 3
2024-11-30 17:03:10 -08:00
// @author Swee
// @description Fork of https://forum.snap.berkeley.edu/t/18272
2024-11-30 17:31:10 -08:00
// @run-at document-idle
2024-11-30 17:00:33 -08:00
// ==/UserScript==
//
if (document.querySelectorAll('[data-bs-theme]').length > 0) {
2024-11-30 17:00:33 -08:00
// 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');
2024-11-30 17:27:20 -08:00
document.documentElement.classList.add("text-white"); // Make the text white with a class, rather than custom CSS.
2024-11-30 17:29:53 -08:00
console.info("This page uses BS5.")
2024-11-30 17:00:33 -08:00
} else {
// Dark mode patches for non-bootstrap pages
const noBoostrapStyle = document.createElement('style');
noBoostrapStyle.innerHTML = `
body {
background: #212529;
2024-11-30 17:27:20 -08:00
color: white;
2024-11-30 17:00:33 -08:00
}
.notes {
background: #2D3142 !important;
}
.trapezoid {
color: #2D3142;
}
2024-11-30 17:27:20 -08:00
.trapezoid-footer {
color: #212529;
}
2024-11-30 17:00:33 -08:00
`;
document.head.appendChild(noBoostrapStyle);
2024-11-30 17:29:53 -08:00
console.info("This page does NOT use BS5.")
2024-11-30 17:00:33 -08:00
}
2024-11-30 17:27:20 -08:00
document.head.appendChild(style);