Compare commits

..

1 Commits

Author SHA1 Message Date
8c9fe4d286 Rewrite 2025-05-15 22:30:21 -04:00

View File

@ -18,8 +18,7 @@ globalThis.document.styleSheets[0].insertRule('tbody tr.athing>td.title>span.tit
const requery = () => globalThis.document.querySelectorAll('tbody tr.athing')
let
query = requery(),
selected = -1,
lastCollapsed
selected = -1
const
// This is a Firefox only option. For some reason older versions of Firefox can't set outline: none.
focusInvisible = { __proto__: null, focusVisible: false },
@ -37,35 +36,26 @@ const
keydown = event => {
switch (event.key) {
case 'j':
const lastIndex = query.length - 1
if (selected === lastIndex)
if (selected + 1 === query.length)
return
if (selected !== -1)
query[selected].style.boxShadow = ''
let hiddenChain = 0
while (selected < lastIndex) {
const hidden = query[++selected].classList.contains('noshow')
hiddenChain = hiddenChain * hidden + hidden
while (selected < query.length && query[++selected].classList.contains('noshow'));
if (!hidden) {
lastCollapsed = query[selected].classList.contains('coll') ? selected : undefined
break
}
}
selected -= hiddenChain * (selected - hiddenChain === lastCollapsed)
highlightSelected()
if (!query[selected].classList.contains('noshow'))
highlightSelected()
return
case 'k':
if (selected <= 0)
return
query[selected].style.boxShadow = ''
while (selected >= 0 && query[--selected].classList.contains('noshow'));
highlightSelected()
if (!query[selected].classList.contains('noshow'))
highlightSelected()
return
case 'h':
if (globalThis.location.pathname === '/hidden')
@ -77,7 +67,7 @@ const
else
query[selected].nextSibling.querySelector('a.clicky.hider')?.click()
if (selected + 1 <= query?.length)
if (selected + 1 <= query.length && !query[selected].classList.contains('noshow'))
highlightSelected()
return
case 'c':