gdh1995 / vimium-c

A keyboard shortcut browser extension for keyboard-based navigation and tab operations with an advanced omnibar
https://chrome.google.com/webstore/detail/vimium-c/hfjbmagddngcpeloejdejnfgbamkjaeg
Other
3.17k stars 253 forks source link

element-based navigation #1129

Open KiaraGrouwstra opened 1 month ago

KiaraGrouwstra commented 1 month ago

What command or commands

Add a new mode to navigate elements on a page, not unlike arrow keys on duckduckgo.

How should a feature do

When a user has done such steps:

  1. Go to a URL with vertically placed items, e.g. https://github.com/gdh1995/vimium-c/issues
  2. Press a key (maybe c?)
  3. Start pressing arrow-like keys (down / up, j / k)

then Vimium C should do:

  1. Highlight, scroll to the right element, and focus its link to open if desired.

The user should also be able to exit this mode again.

I made something like this here (not tested as well with SPAs).

gdh1995 commented 1 month ago

You may use LinkHints.click to switch focus among some elements.

For example, on a Google search result page, this will switch focus among search result items:

map xxx LinkHints.click mode="focus" match="a:has(h3)" directOptions={"offset":"cur","search":"doc","loop":1}
# then `xxx` will go down and `-xxx` will go up

Note: loop in directOptions requires Vimium C v2.0+ .

KiaraGrouwstra commented 1 month ago

that's pretty cool! i hadn't realized vimium already offered things like this. i feel that approach may still pose a barrier to casual users though, as it both requires a basic understanding of CSS selectors, while selectors like a:has(h3) are also circumstantial, making them harder to reuse across a wider range of web pages. i'll admit the attempt i made also wasn't really perfect yet. but it'd be nice to see more general approaches explored here as well.

gdh1995 commented 1 month ago

Yes a:has(h3) is too exact to reuse - it may not work on other websites.

You may use env to bind one key to multiple commands, like:

As for CSS knowledge, because Vimium C is designed to "advanced computer users" (especially programmers), it would not block Vimium C users, I guess.