all repos — honk @ f253f3bbeee9e2195b4a08aaf32ddd638ff997bd

my fork of honk

use mutation observer
Anirudh Oppiliappan x@icyphox.sh
Fri, 15 Mar 2024 12:03:06 +0200
commit

f253f3bbeee9e2195b4a08aaf32ddd638ff997bd

parent

b4c436d48b5319ab112317ac4c4a31bc12037671

1 files changed, 19 insertions(+), 10 deletions(-)

jump to
M views/honkpage.jsviews/honkpage.js

@@ -549,16 +549,25 @@ curpagestate.arg = me.dataset.pagearg

tophid[curpagestate.name + ":" + curpagestate.arg] = me.dataset.tophid servermsgs[curpagestate.name + ":" + curpagestate.arg] = me.dataset.srvmsg - var mecount = document.getElementById("mecount") - if (mecount.innerHTML == "" ) { - mecount.style.width = "0px" - } else { - mecount.style.width = "18px" - if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) { - mecount.style.backgroundColor = "var(--bg-page)" - mecount.style.color = "var(--fg-subtle)" - } - } + var mecountobserver = new MutationObserver(function(mutations) { + mutations.forEach(function(mutation) { + if (mutation.type == "childList") { + var m = mutation.target + if (m.innerHTML !== "") { + m.style.width = "18px" + if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) { + m.style.backgroundColor = "var(--bg-page)" + m.style.color = "var(--fg-subtle)" + } + } else { + m.style.width = "0px" + } + } + }) + }) + + mecountobserver.observe(document.getElementById("mecount"), { childList: true }) + var el = document.getElementById("homelink") el.onclick = pageswitcher("home", "") el = document.getElementById("atmelink")