Compare commits

..

3 Commits

Author SHA1 Message Date
4fc5818693 Bump ver 2025-05-09 13:44:12 -04:00
b5d1dd89a3 Set branch-specific URIs 2025-05-09 13:44:12 -04:00
a4190b4e7e Rewrite 2025-05-09 13:44:11 -04:00

View File

@ -2,10 +2,10 @@
// @name ycombinator-keys
// @namespace https://gitea.amine-bouabdallaoui.fr/AmineB/ycombinator-keys
// @license gpl-3.0-only
// @match *://news.ycombinator.com/*
// @match http*://news.ycombinator.com/*
// @icon https://gitea.amine-bouabdallaoui.fr/AmineB/ycombinator-keys/raw/branch/main/icons/48.png
// @grant none
// @version 11
// @version 5
// @author AmineB
// @description Ycombinator keyboard nav.
// @downloadURL https://gitea.amine-bouabdallaoui.fr/brian6932/ycombinator-keys/raw/branch/main/keyboard-watcher.user.js
@ -18,12 +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,
lastCollapsed
selected = -1
const
input = new Set()
.add('INPUT')
.add('TEXTAREA'),
// This is a Firefox only option. For some reason older versions of Firefox can't set outline: none.
focusInvisible = { __proto__: null, focusVisible: false },
isComment = () => query[selected].classList.contains('comtr'),
@ -38,28 +34,15 @@ const
query[selected].lastChild.firstChild.firstChild.focus(focusInvisible)
},
keydown = event => {
if (!input.has(event.target.tagName))
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
if (!hidden) {
lastCollapsed = query[selected].classList.contains('coll') ? selected : undefined
break
}
}
selected -= hiddenChain * (selected - hiddenChain === lastCollapsed)
while (selected < query.length && query[++selected].classList.contains('noshow'));
highlightSelected()
return
case 'k':
@ -67,7 +50,6 @@ const
return
query[selected].style.boxShadow = ''
while (selected >= 0 && query[--selected].classList.contains('noshow'));
highlightSelected()
return
@ -80,7 +62,6 @@ const
}
else
query[selected].nextSibling.querySelector('a.clicky.hider')?.click()
if (selected + 1 <= query.length)
highlightSelected()
return