From 0c4b8521b4d33f3d849e16076a69dcdee7b9bbd7 Mon Sep 17 00:00:00 2001 From: sethburkart123 Date: Wed, 19 Jun 2024 14:48:33 +1000 Subject: [PATCH] perf: remove document color change observer --- src/SEQTA.ts | 33 --------------------------------- src/css/injected.scss | 11 +++++++++++ 2 files changed, 11 insertions(+), 33 deletions(-) diff --git a/src/SEQTA.ts b/src/SEQTA.ts index b28ea986..d9b8cc3e 100644 --- a/src/SEQTA.ts +++ b/src/SEQTA.ts @@ -698,12 +698,9 @@ export function tryLoad() { 'load', function () { removeThemeTagsFromNotices() - documentTextColor() }, true, ) - const observer = new MutationObserver(() => { documentTextColor() }) - observer.observe(document!, { attributes: true, childList: true, subtree: true, attributeFilter: ['td'], }) } function ChangeMenuItemPositions(storage: any) { @@ -2490,34 +2487,4 @@ async function CheckForMenuList() { return } } -} - -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') - } - } } \ No newline at end of file diff --git a/src/css/injected.scss b/src/css/injected.scss index c318112b..0a4df748 100644 --- a/src/css/injected.scss +++ b/src/css/injected.scss @@ -1672,6 +1672,17 @@ div.entry.class[style*="width: 46.5%"] { 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 { border: 12px solid rgba(0, 0, 0, 0); border-top-color: var(--background-primary);