Compare commits
1 Commits
8c9fe4d286
...
f20d99abf1
Author | SHA1 | Date | |
---|---|---|---|
f20d99abf1 |
@ -18,7 +18,8 @@ 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
|
||||
selected = -1,
|
||||
lastCollapsed
|
||||
const
|
||||
// This is a Firefox only option. For some reason older versions of Firefox can't set outline: none.
|
||||
focusInvisible = { __proto__: null, focusVisible: false },
|
||||
@ -36,26 +37,35 @@ const
|
||||
keydown = event => {
|
||||
switch (event.key) {
|
||||
case 'j':
|
||||
if (selected + 1 === query.length)
|
||||
const lastIndex = query.length - 1
|
||||
if (selected === lastIndex)
|
||||
return
|
||||
|
||||
if (selected !== -1)
|
||||
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'))
|
||||
highlightSelected()
|
||||
if (!hidden) {
|
||||
lastCollapsed = query[selected].classList.contains('coll') ? selected : undefined
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
selected -= hiddenChain * (selected - hiddenChain === lastCollapsed)
|
||||
highlightSelected()
|
||||
return
|
||||
case 'k':
|
||||
if (selected <= 0)
|
||||
return
|
||||
|
||||
query[selected].style.boxShadow = ''
|
||||
while (selected >= 0 && query[--selected].classList.contains('noshow'));
|
||||
|
||||
if (!query[selected].classList.contains('noshow'))
|
||||
highlightSelected()
|
||||
while (selected >= 0 && query[--selected].classList.contains('noshow'));
|
||||
highlightSelected()
|
||||
return
|
||||
case 'h':
|
||||
if (globalThis.location.pathname === '/hidden')
|
||||
@ -67,7 +77,7 @@ const
|
||||
else
|
||||
query[selected].nextSibling.querySelector('a.clicky.hider')?.click()
|
||||
|
||||
if (selected + 1 <= query.length && !query[selected].classList.contains('noshow'))
|
||||
if (selected + 1 <= query?.length)
|
||||
highlightSelected()
|
||||
return
|
||||
case 'c':
|
||||
|
Loading…
x
Reference in New Issue
Block a user