perf: remove document color change observer

This commit is contained in:
sethburkart123
2024-06-19 14:48:33 +10:00
parent 25520208da
commit 0c4b8521b4
2 changed files with 11 additions and 33 deletions
-33
View File
@@ -698,12 +698,9 @@ export function tryLoad() {
'load', 'load',
function () { function () {
removeThemeTagsFromNotices() removeThemeTagsFromNotices()
documentTextColor()
}, },
true, true,
) )
const observer = new MutationObserver(() => { documentTextColor() })
observer.observe(document!, { attributes: true, childList: true, subtree: true, attributeFilter: ['td'], })
} }
function ChangeMenuItemPositions(storage: any) { function ChangeMenuItemPositions(storage: any) {
@@ -2491,33 +2488,3 @@ async function CheckForMenuList() {
} }
} }
} }
export function documentTextColor() {
if (settingsState.DarkMode) {
const documentArray = document.querySelectorAll('td:not([class^="colourBar"]):not([class^="title"])')
const fullDocArray = document.querySelectorAll('tr.document')
const linkArray = document.querySelectorAll('a.uiFile')
for (const item of fullDocArray) {
item.classList.add('documentDark')
}
for (const item of linkArray) {
item.setAttribute('style', 'color: #06b4fc;')
}
for (const item of documentArray) {
item.setAttribute('style', 'color: white')
}
} else {
const documentArray = document.querySelectorAll('td:not([class^="colourBar"]):not([class^="title"])')
const fullDocArray = document.querySelectorAll('tr.document')
const linkArray = document.querySelectorAll('a.uiFile')
for (const item of fullDocArray) {
item.classList.remove('documentDark')
}
for (const item of linkArray) {
item.setAttribute('style', 'color: #3465a4;')
}
for (const item of documentArray) {
item.setAttribute('style', 'color: black')
}
}
}
+11
View File
@@ -1672,6 +1672,17 @@ div.entry.class[style*="width: 46.5%"] {
margin-top: 4px !important; margin-top: 4px !important;
} }
.dark .title a.uiFile {
color: #06b4fc !important;
}
.document td:not([class^="colourBar"]):not([class^="title"]) {
color: black;
}
.dark .document td:not([class^="colourBar"]):not([class^="title"]) {
color: white !important;
}
.uiFileHandlerPanel::before { .uiFileHandlerPanel::before {
border: 12px solid rgba(0, 0, 0, 0); border: 12px solid rgba(0, 0, 0, 0);
border-top-color: var(--background-primary); border-top-color: var(--background-primary);