-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfixGitHubChangelogColorMode.user.js
More file actions
47 lines (40 loc) · 1.74 KB
/
fixGitHubChangelogColorMode.user.js
File metadata and controls
47 lines (40 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// ==UserScript==
// @name fixGitHubChangelogColorMode
// @description Make the GitHub changelog adapt to the browser colour scheme.
// @version 1.0.0
// @namespace https://github.com/ravindUwU/dotfiles
// @downloadURL https://github.com/__raw/ravindUwU/dotfiles/main/firefox/violentmonkey/fixGitHubChangelogColorMode.user.js
// @homepageURL https://github.com/ravindUwU/dotfiles/blob/main/firefox/violentmonkey/fixGitHubChangelogColorMode.user.js
// @match https://github.blog/changelog/*
// ==/UserScript==
/*
The GitHub changelog is stuck in dark mode. Seeing the [data-color-mode="dark"] everywhere, I
think they're forcing dark mode? Do they think "all devs use dark mode" and "dark mode cool" or
whatever, and that this is appropriate because their target audience is developers?
Regardless, this is *not* cool. When there's a lot of ambient light, dark mode is hard to read
and stresses your eyes out and requires that you bump up the brightness on your screen; and
vice-versa. Do the decent thing and honour your users' light/dark mode preference, GitHub.
https://github.com/orgs/community/discussions/179127
*/
(() => {
if (document.body.dataset.dotfilesFixedColorMode === 'yeppers') return;
document.body.dataset.dotfilesFixedColorMode = 'yeppers';
const mql = window.matchMedia('(prefers-color-scheme: light)');
function fix() {
if (mql.matches) {
for (const el of document.querySelectorAll('[data-color-mode="dark"]')) {
if (el instanceof HTMLElement) {
el.dataset.colorMode = 'light';
}
}
} else {
for (const el of document.querySelectorAll('[data-color-mode="light"]')) {
if (el instanceof HTMLElement) {
el.dataset.colorMode = 'dark';
}
}
}
}
fix();
mql.addEventListener('change', fix);
})();