-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsuperscript.js
44 lines (35 loc) · 1.29 KB
/
superscript.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
function onPageLoad() {
const header = document.querySelector('.notion-header');
const html = document.querySelector('html');
const footerCover = () => {
const footerCoverNode = document.querySelector('.footer-cover');
if(footerCoverNode){
footerCoverNode.remove();
}
const cover = document.querySelector('.notion-header__cover');
const clone = cover.cloneNode(true);
clone.classList.add('footer-cover');
clone.classList.remove('notion-header__cover', 'has-cover');
const content = document.querySelector('.super-content');
content.appendChild(clone);
}
footerCover();
const setTheme = () => {
const savedTheme = localStorage.getItem("theme");
html.className = '';
html.classList.add(savedTheme);
}
const config = { subtree: true, characterData: true };
const callback = function(mutationsList, observer) {
for (const mutation of mutationsList) {
if (mutation.type === 'characterData') {
footerCover();
setTheme();
toggleTheme();
}
}
};
const observer = new MutationObserver(callback);
observer.observe(header, config);
}
document.addEventListener("DOMContentLoaded", onPageLoad);