Vim风格导航(带设置+增强模块)

在网页中提供 Vim 风格操作:滚动(hjkl / d u / gg G)、链接提示(f/F)、查找(/ n/N)、历史(H/L)、页面操作(r t x*)、杂项(yy p o ?)。已针对 UserScript 权限做安全降级。

作者
bianwenbo
日安装量
0
总安装量
0
评分
0 0 0
版本
2.2.0
创建于
2025-08-31
更新于
2025-09-01
大小
20.6 KB
许可证
MIT
适用于
所有网站

Vim Style Navigation (with Settings + Enhanced)

A Tampermonkey userscript that brings Vim-style navigation to the web:

  • Scrolling: hjkl, d/u, gg/G
  • Link hints: f / F
  • Find: /, n / N
  • History: H / L
  • Page ops: r, t, x*
  • Misc: yy, p, o, ?

* x can only close tabs that were opened by scripts (browser restriction).


✨ Features

Scrolling

  • h / l — scroll left/right
  • j / k — scroll down/up
  • d / u — page down/up (distance = baseStep + extraPage)
  • gg / G — jump to top/bottom

Link Hint

  • f — open hinted link in current tab
  • F — open hinted link in new tab (uses GM_openInTabwindow.open fallback)

Find

  • / — open lightweight find bar
  • n / N — next / previous match (based on window.find)

History & Page Ops

  • H — back, L — forward
  • r — reload, t — new tab, x — close tab*
  • J/K tab switching is not available in UserScript due to browser permissions.

Misc

  • yy — copy current page URL (clipboard API / GM fallback)
  • p — open URL from clipboard (or prompt fallback)
  • o — open URL or search (prompt)
  • ? — help overlay

Smart input detection: Hotkeys are disabled inside INPUT / TEXTAREA / SELECT / contentEditable / designMode=on.


⚙️ Settings (Tampermonkey Menu)

Open Tampermonkey → this script → Menu Commands to adjust:

  • Base Step (baseStep, default 100)
  • Extra Page (extraPage, default 300)
  • gg Interval (ggIntervalMs, default 600 ms)
  • Native Smooth Scroll (useNativeSmooth, on/off)
  • Ignore Modifier Keys (ignoreWithModifier, on/off)
  • Exclude Sites: add/remove URL prefixes or regex (e.g. /.*\.notion\.site\//)
  • Hint Chars (hintChars), Hint Max Letters (hintMaxLetters)
  • Reset Defaults

🚀 Installation

  1. Install Tampermonkey for your browser.
  2. Add this userscript (paste raw URL or code).
  3. Refresh any page and start using Vim keys.

🛡️ Permissions & Notes

  • Uses GM_openInTab, GM_setClipboard, GM_getValue/GM_setValue, GM_registerMenuCommand.
  • Clipboard read may require HTTPS and user permission; script falls back to prompt when needed.
  • Some sites use custom scroll containers; extreme layouts may reduce hint accuracy.
  • Recommended to exclude heavy editors: Google Docs, Notion, Figma, Gmail, etc.
  • UserScript cannot switch browser tabs programmatically (security limitation).

❓ Troubleshooting

  • Keys don’t work: Check if focus is inside an input/editor; confirm the site isn’t in the exclude list.
  • x doesn’t close: Browsers only allow scripts to close tabs that they opened.
  • Clipboard issues: Grant permission or use the prompt fallback.
  • Conflicts: If a site uses the same keys, enable “Ignore Modifier Keys” or add the site to Exclude.

🗺️ Keymap (Quick Reference)

Category Keys Action
Scroll j / k Down / Up
h / l Left / Right
d / u Page Down / Up (base+extra)
gg / G Top / Bottom
Hint f / F Open link (current / new tab)
Find /, n / N Open find, Next / Prev
History H / L Back / Forward
Page r / t / x Reload / New tab / Close tab*
Misc yy / p / o / ? Copy URL / Open from clipboard / Open or search / Help

📜 License

MIT License © Wenbo Bian