/
google-chrome-dark-mode-exceptions.js
53 lines (45 loc) · 1.25 KB
/
google-chrome-dark-mode-exceptions.js
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
48
49
50
51
52
53
// ==UserScript==
// @name google-chrome-dark-mode-exceptions
// @namespace http://tampermonkey.net/
// @version 20240131
// @description Google Chrome Dark Mode Exceptions
// @author Rafael David Tinoco
// @match *://*/*
// @grant GM_addStyle
// @run-at document-start
// ==/UserScript==
// To be used after chrome://flags => #enable-force-dark is enabled.
; (function () {
'use strict'
let defaultMode = 'dark' // or "light"
// Do not apply chrome's default dark mode to site
const excludedDomains = [
'github.com',
'docs.google.com',
'drive.google.com',
'docusign',
]
function isExcluded() {
const currentDomain = window.location.hostname
return excludedDomains.find(domain => currentDomain.includes(domain))
}
const lightCSS = `
:root {
color-scheme: light only !important;
}
`
const darkCSS = `
:root {
color-scheme: darkonly !important;
}
`
if (defaultMode === 'dark') {
if (isExcluded()) {
GM_addStyle(lightCSS)
}
} else if (defaultMode === 'light') {
if (isExcluded()) {
GM_addStyle(darkCSS)
}
}
})()