vimium-c icon indicating copy to clipboard operation
vimium-c copied to clipboard

element-based navigation

Open KiaraGrouwstra opened this issue 1 year ago • 4 comments

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).

KiaraGrouwstra avatar May 09 '24 16:05 KiaraGrouwstra

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+ .

gdh1995 avatar May 22 '24 17:05 gdh1995

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.

KiaraGrouwstra avatar May 22 '24 20:05 KiaraGrouwstra

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:

  • an example is https://github.com/gdh1995/vimium-c/issues/1132#issuecomment-2135856990
  • the syntax is https://github.com/gdh1995/vimium-c/wiki/Map-a-key-to-different-commands-on-different-websites

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

gdh1995 avatar May 28 '24 18:05 gdh1995