SHOW:
|
|
- or go back to the newest paste.
1 | let root = document.getElementsByTagName("html")[0]; | |
2 | let className = "custom-theme-background"; | |
3 | ||
4 | const options = { | |
5 | attributes: true | |
6 | } | |
7 | ||
8 | function callback(mutationList, observer) { | |
9 | mutationList.forEach(function(mutation) { | |
10 | if (mutation.type === 'attributes' && mutation.attributeName === 'class') { | |
11 | if (root.classList.contains(className)) return; | |
12 | document.getElementsByTagName("html")[0].classList.add(className) | |
13 | ||
14 | var head = document.head || document.getElementsByTagName('head')[0], | |
15 | style = document.createElement('style'); | |
16 | ||
17 | var css = '.custom-theme-background {--custom-theme-background: linear-gradient(128.92deg, var(--bg-gradient-chroma-glow-1) 3.94%, var(--bg-gradient-chroma-glow-2) 26.1%, var(--bg-gradient-chroma-glow-3) 39.82%, var(--bg-gradient-chroma-glow-4) 56.89%, var(--bg-gradient-chroma-glow-5) 76.45%);}'; | |
18 | ||
19 | head.appendChild(style); | |
20 | style.appendChild(document.createTextNode(css)); | |
21 | } | |
22 | }) | |
23 | } | |
24 | ||
25 | const observer = new MutationObserver(callback) | |
26 | observer.observe(root, options) |