Giter Club home page Giter Club logo

vihn's Introduction

ViHN

Vi-style key bindings for browsing Hacker News.

It's fast. If you have to wait a perceptible amount of time, that's a bug.

Get the Add-on Available in the Chrome Web Store

Compatible with Hacker News Night Mode. See also Vimium.

Features

This browser extension is compatible with Firefox and Chrome. Use the key bindings similar to Vi to navigate Hacker News stories and comments. It should work on story listings (front page, /new, /newest, /best, user submissions, etc.), comment threads, and comment listings (user comments, etc.).

Also, you can quickly find new comments by hitting “n” to browse comments in inverse chronological order.

In addition, the quick-reply and quick-edit forms let you see a preview of the comment you are writing.

Finally, the original poster (OP) is highlighted in comments.

Demo.mp4

Key bindings

Press ? to toggle help.

Note: Like in Vim mapping, case is important. So j means hitting the j key with Caps Lock disabled, and without holding Shift. But J means hitting j key with either Caps Lock enabled, or while holding Shift.

Navigate Comments/Stories

Key Effect
j Next comment/story
k Previous comment/story
J Next sibling comment
K Previous sibling comment
g Go to first story/comment
G Go to last story, last root comment or “More” link
H Focus on story/comment at the top of the screen (high)
M Focus on story/comment in the middle of the screen
L Focus on story/comment at the bottom of the screen (low)
n Switch to Newest Items
h Parent comment/story (see [#follow-links](Follow Links))
p Parent comment/story (see [#follow-links](Follow Links))

Note: You can also select an item by clicking in its bounding box.

Follow links

Key Effect
o Open story link/comment
O Open story link/comment in background
c Open comment thread
C Open comment thread in background
b Open both story link and comment thread
B Open both story link and comment thread in background
h Follow “context” link (go to comment thread, but focus on current comment)
p Follow “parent” link (go to parent's page, and focus on parent comment/story)
1 Open 1st link in comment (maintain shift to open in background)
9 Open 9th link in comment (maintain shift to open in background)
0 Open 10th link in comment (maintain shift to open in background)

Note: When on the “XXX more comments” link, you can hit either of [lLcC] to go to the next page of comments.

Note: The digits of the numeric keypad work as well to open links in comments. However, this can only open links in foreground.

Note: When using AZERTY, the key bindings to open links inside comments still work like in QWERTY. Hit the 1 key without shift (like typing &) to open the 1st link in foreground. Hit the 1 key with shift (like typing 1) to open the 1st link in background. Same for the other link numbers.

Actions

Key Effect
m Collapse/uncollapse comment tree
u Upvote story/comment, or cancel vote
d Downvote story/comment, or cancel vote
f Favorite/un-favorite story/comment of the current page
F Flag/unflag story/comment of the current page
r Comment on story, or reply to comment (with preview)
e Edit comment (with preview)
D Delete comment
Ctrl+Return Submit current form

Navigate Newest Items

In the Newest Items list, the following key bindings are available:

Key Effect
l Show selected comment/story
j Next comment/story
k Previous comment/story
J Jump 10 down
K Jump 10 up
g Go to top story/comment
G Go to last story/comment
n Switch back from Newest Items

vihn's People

Contributors

qsantos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

hbcbh1999

vihn's Issues

Compatibility with Wayback Archive

Note that older versions of Hacker News might have different structures. In particular, story ages did not have a title attribute in 2020.

Review key bindings

This is too inconsistent:

  • h: Parent comment (stay in context when changing page)
  • p: Parent comment (always go directly to parent)
  • l: Open story link/comment permalink
  • b: Open story link/comment permalink in background
  • c: Open comments
  • C: Open comments in background

Because:

  • h and p cannot be opened in background
  • l and o break and intuitive pattern

Solution:

  • think about h in background; maybe g? still inconsistent
  • consider adding P to open parent in background
  • change binding for l/o; for instance o/O for “open”
  • fix documentation in AMO
  • fix documentation in Chrome Store

Reduce noise in long-term history

When navigating comments, URL changes are not added to the immediate history (navigating back/forward in the browser). This avoids breaking the back button too much.

However, the IRLs are still present in the long term history, cluttering searches.

Preview comment

Hacker News comment formatting is not complex but trips many users. A simple preview of the comment being edited should be available.

Keep non-hash URL in history

Navigating comments adds a hash to the URL. Using the back button does not help in removing it.

Things to take into consideration:

  • if the page was initially loaded with a hash, it should be kept (what about hash charges)
  • it should still be possible to access the URL pointing to the current comment; in particular, coding the browser and reopening it should navigate back to the comment where the user was at

Feature comparison with Refined Hacker News

This issue is dedicated to listing the features of the Refined Hacker News extension, as a source of ideas. ViHN aims for a tighter scope, so it won't implement most features of Refined Hacker News.

  • archive-submission.js
  • auto-refresh.js
  • backticks-to-monospace.js
  • change-dead-comments-color.js
  • collapse-root-comment.js
  • click-comment-indent-to-toggle.js
  • click-rank-to-vote-unvote.js
  • comments-ui-tweaks.js
    • Add border to indentation to make to show indent separation between comments.
    • ✅ Highlight item's original poster, displayed as [op] next to username.
    • Custom indent-width (default is 40px), which can be set using the extension popup.
    • Make <pre></pre> tags more visible.
  • fetch-submission-title-from-url.js
  • hide-read-stories.js
  • highlight-unread-comment.js
  • input-field-tweaks.js
    • Show how many characters are left in the 'title' field when submitting an item.
    • Increase width of 'title' field dynamically.
    • Increase height of any textareas (even those that are dynamically created), dynamically.
  • key-bindings-on-input-fields.js
    • ✅ Ctrl+Enter to submit form
    • Ctrl+I to italicise
  • key-bindings-on-items.js
    • stories
      • ✅ Next item (down)
      • ✅ Previous item (up)
      • ✅ Open link and focus tab
      • ✅ Open link in the background
      • Un-highlight item
      • ✅ Upvote item
      • ✅ Favorite item
      • Open item's comments on same tab
      • ✅ Open item's comments on new tab
      • ✅ Flag/unflag item
      • Hide item
    • comments
      • ✅ Next comment (down)
      • ✅ Next direct sibling comment
      • ✅ Previous comment (down)
      • ✅ Previous direct sibling comment
      • ✅ Toggle comment
      • Un-highlight comment
      • ✅ Upvote/unvote comment
      • ✅ Downvote/undown comment
      • ✅ Reply to comment
      • ✅ Favorite comment
      • ✅ Flag/unflag comment
      • Open numbered/index reference link in the comment
  • linkify-user-about.js
  • list-hn-polls-separately.js
  • load-more-links-in-navbar.js
  • more-accessible-favorite.js
  • more-accessible-flag.js
  • on-link-focus-comment.js
  • open-story-links-in-new-tab.js
  • past-choose-date.js
  • prefill-submit-title.js
  • preview-and-set-top-bar-color.js
  • profile-links-dropdown.js
  • reply-without-leaving-page.js
    • ✅ reply
    • ✅ edit
    • ✅ delete-confirm
  • show-item-info-on-hover.js
  • show-similar-submissions.js
  • show-top-leaders-karma.js
  • show-user-info-on-hover.js
  • site-navigation-key-bindings.js
  • sort-stories.js
  • toggle-all-comments-and-replies.js

Display list of newest comments

Refined Hacker News highlights new comments, but finding them means scrolling through the whole comment tree. Instead, there should be a simple way to find the newest comments. Maybe something like the upper right popup on SlateStarCodex articles.

  • show list of latest comments
  • jump to comment from the list
  • uncollapse parents if needed
  • disclaimer that this only looks at this page comment when there are other pages (previous or next)
  • keyboard-based navigation in latest comment list
  • make it look proper in smaller windows

Proper error handling

I have not bothered yet with proper handling, favoring fast iterations. However, the submission of a quick reply form could fail when the Internet connection is lost, the user is logged out, or Hacker News is down. The error handling should make sure that the user's content is not swallowed by an error page.

Improve support for mixed workflows

The current workflows are mostly designed to be keyboard-only, albeit without interfering with the existing mouse-only workflows. However, this means that certain features might not work as expected

  • focusing the “new comment” form manually does not enable preview
  • clicking on a “reply”/“edit”/“delete” link does not enable quick-reply/edit/delete
  • clicking on a vote arrow, or an “unvote”/“undown”/“favorite”/“un-favorite”/“flag”/“un-flag” link, or {un,}collapsing comments do not use the 503-safe system

Addon options

  • toggle smooth scrolling
  • toggle saving collapsed threads
  • toggle Newest Items

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.