Compare commits

..

1 Commits

Author SHA1 Message Date
f20d99abf1 Rewrite 2025-05-16 00:26:26 -04:00

View File

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