finally fix mecount after like 2 years
Anirudh Oppiliappan x@icyphox.sh
Sat, 10 Aug 2024 11:45:34 +0300
2 files changed,
14 insertions(+),
3 deletions(-)
M
views/header.html
→
views/header.html
@@ -29,6 +29,19 @@ <nav>
<ul class="easylinks"> <li><a id="homelink" href="/">home</a> <li><a id="atmelink" href="/atme">@me<span id=mecount>{{ if .UserInfo.Options.MeCount }}{{ .UserInfo.Options.MeCount }}{{ end }}</span></a> + <script> + var mecount = document.getElementById("mecount"); + if (mecount.innerHTML !== "") { + 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)" + } + } else { + mecount.style.width = "0px"; + } + + </script> <li><a href="/account">account</a> <li><a href="/honkers">honkers</a> <li><a href="/{{ .UserSep }}/{{ .UserInfo.Name }}">{{ .UserInfo.Name }}</a>
M
views/mecount.js
→
views/mecount.js
@@ -3,7 +3,7 @@ var mecountobserver = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) { if (mutation.type == "childList") { var m = mutation.target - if (m.innerHTML !== "") { + if (m.innerHTML) { m.style.width = "18px" if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) { m.style.backgroundColor = "var(--bg-page)"@@ -12,8 +12,6 @@ }
} else { m.style.width = "0px" } - - document.title = document.title + " (" + m.innerHTML + ")" } }) })