forked from AmineB/ycombinator-keys
Compare commits
3 Commits
c1fcffa943
...
main
Author | SHA1 | Date | |
---|---|---|---|
27e1c54451
|
|||
3e431c552b
|
|||
86026e4839
|
@ -5,7 +5,7 @@
|
|||||||
// @match *://news.ycombinator.com/*
|
// @match *://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 8
|
// @version 11
|
||||||
// @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.user.js
|
// @downloadURL https://gitea.amine-bouabdallaoui.fr/brian6932/ycombinator-keys/raw/branch/main/keyboard-watcher.user.js
|
||||||
@ -21,6 +21,9 @@ let
|
|||||||
selected = -1,
|
selected = -1,
|
||||||
lastCollapsed
|
lastCollapsed
|
||||||
const
|
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.
|
// 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'),
|
isComment = () => query[selected].classList.contains('comtr'),
|
||||||
@ -35,6 +38,7 @@ const
|
|||||||
query[selected].lastChild.firstChild.firstChild.focus(focusInvisible)
|
query[selected].lastChild.firstChild.firstChild.focus(focusInvisible)
|
||||||
},
|
},
|
||||||
keydown = event => {
|
keydown = event => {
|
||||||
|
if (!input.has(event.target.tagName))
|
||||||
switch (event.key) {
|
switch (event.key) {
|
||||||
case 'j':
|
case 'j':
|
||||||
const lastIndex = query.length - 1
|
const lastIndex = query.length - 1
|
||||||
@ -77,7 +81,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)
|
if (selected + 1 <= query.length)
|
||||||
highlightSelected()
|
highlightSelected()
|
||||||
return
|
return
|
||||||
case 'c':
|
case 'c':
|
||||||
|
Reference in New Issue
Block a user