Add script.js
This commit is contained in:
parent
bdb8bce5e4
commit
130bac492c
1 changed files with 50 additions and 0 deletions
50
script.js
Normal file
50
script.js
Normal file
|
@ -0,0 +1,50 @@
|
|||
// ==UserScript==
|
||||
// @name Snap! Dark Theme
|
||||
// @namespace Violentmonkey Scripts
|
||||
// @match https://snap.berkeley.edu/*
|
||||
// @grant none
|
||||
// @version 1.0
|
||||
// @author ampelectrecuted
|
||||
// @description A dark theme for Snap!
|
||||
// ==/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()) {
|
||||
// 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');
|
||||
} else {
|
||||
// Dark mode patches for non-bootstrap pages
|
||||
const noBoostrapStyle = document.createElement('style');
|
||||
noBoostrapStyle.innerHTML = `
|
||||
body {
|
||||
background: #212529;
|
||||
}
|
||||
.notes {
|
||||
background: #2D3142 !important;
|
||||
}
|
||||
.trapezoid {
|
||||
color: #2D3142;
|
||||
}
|
||||
`;
|
||||
document.head.appendChild(noBoostrapStyle);
|
||||
}
|
||||
|
||||
// Apply styles to force body to white
|
||||
const style = document.createElement('style');
|
||||
style.innerHTML = `
|
||||
body {
|
||||
color: white;
|
||||
}
|
||||
.trapezoid-footer {
|
||||
color: #212529;
|
||||
}
|
||||
`;
|
||||
document.head.appendChild(style);
|
Loading…
Reference in a new issue