forked from AmineB/ycombinator-keys
Compare commits
3 Commits
rewrite
...
c1fcffa943
Author | SHA1 | Date | |
---|---|---|---|
c1fcffa943
|
|||
f7bd78189a
|
|||
ffc97281ad
|
@ -5,11 +5,11 @@
|
||||
// @match *://news.ycombinator.com/*
|
||||
// @icon https://gitea.amine-bouabdallaoui.fr/AmineB/ycombinator-keys/raw/branch/main/icons/48.png
|
||||
// @grant none
|
||||
// @version 4
|
||||
// @version 8
|
||||
// @author AmineB
|
||||
// @description Ycombinator keyboard nav.
|
||||
// @downloadURL https://gitea.amine-bouabdallaoui.fr/AmineB/ycombinator-keys/raw/branch/main/keyboard-watcher.user.js
|
||||
// @updateURL https://gitea.amine-bouabdallaoui.fr/AmineB/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
|
||||
// @updateURL https://gitea.amine-bouabdallaoui.fr/brian6932/ycombinator-keys/raw/branch/main/keyboard-watcher.user.js
|
||||
// ==/UserScript==
|
||||
// jshint esversion: 11
|
||||
|
||||
@ -21,9 +21,6 @@ let
|
||||
selected = -1,
|
||||
lastCollapsed
|
||||
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,7 +35,6 @@ 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
|
||||
@ -81,7 +77,7 @@ const
|
||||
else
|
||||
query[selected].nextSibling.querySelector('a.clicky.hider')?.click()
|
||||
|
||||
if (selected + 1 <= query.length)
|
||||
if (selected + 1 <= query?.length)
|
||||
highlightSelected()
|
||||
return
|
||||
case 'c':
|
||||
|
Reference in New Issue
Block a user