Compare commits

..

2 Commits

Author SHA1 Message Date
1b0613b843
Set branch-specific URIs 2025-04-19 12:53:32 -04:00
11d7538e18
Rewrite 2025-04-19 12:53:27 -04:00

View File

@ -5,7 +5,7 @@
// @match http*://news.ycombinator.com/* // @match http*://news.ycombinator.com/*
// @icon https://gitea.amine-bouabdallaoui.fr/AmineB/ycombinator-keys/raw/branch/main/icons/48.png // @icon https://gitea.amine-bouabdallaoui.fr/AmineB/ycombinator-keys/raw/branch/main/icons/48.png
// @grant none // @grant none
// @version 5 // @version 4
// @author AmineB // @author AmineB
// @description Ycombinator keyboard nav. // @description Ycombinator keyboard nav.
// @downloadURL https://gitea.amine-bouabdallaoui.fr/brian6932/ycombinator-keys/raw/branch/main/keyboard-watcher.js // @downloadURL https://gitea.amine-bouabdallaoui.fr/brian6932/ycombinator-keys/raw/branch/main/keyboard-watcher.js
@ -22,11 +22,10 @@ let
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 },
isComment = () => query[selected].classList.contains('comtr'),
highlightSelected = () => { highlightSelected = () => {
query[selected].style.boxShadow = '0px 0px 10px 4px rgba(0,0,0,0.73)' query[selected].style.boxShadow = '0px 0px 10px 4px rgba(0,0,0,0.73)'
isComment() ? globalThis.location.pathname === '/item' ?
// Drawing the boxShadow on this selector isn't visible enough. // Drawing the boxShadow on this selector isn't visible enough.
query[selected].querySelector('a.togg.clicky')?.focus(focusInvisible) query[selected].querySelector('a.togg.clicky')?.focus(focusInvisible)
: :
@ -72,10 +71,10 @@ const
globalThis.open('https://news.ycombinator.com/item?id=' + query[selected].id) globalThis.open('https://news.ycombinator.com/item?id=' + query[selected].id)
return return
case 'u': case 'u':
globalThis.open((isComment() ? query[selected] : query[selected].nextSibling).querySelector('a.hnuser').href, '_self') globalThis.open((globalThis.location.pathname === '/item' ? query[selected] : query[selected].nextSibling).querySelector('a.hnuser').href, '_self')
return return
case 'U': case 'U':
globalThis.open((isComment() ? query[selected] : query[selected].nextSibling).querySelector('a.hnuser').href) globalThis.open((globalThis.location.pathname === '/item' ? query[selected] : query[selected].nextSibling).querySelector('a.hnuser').href)
} }
}, },
listen = () => globalThis.document.addEventListener('keydown', keydown) listen = () => globalThis.document.addEventListener('keydown', keydown)