Skip to content

leon-zym/chrome-smart-navigation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chrome Smart Navigation

A Chrome Manifest V3 extension prototype for experimenting with "smart" browser navigation at history boundaries.

The goal is to make back and forward commands do something useful even when the current page cannot go back or forward any further.

Current behavior

smart-back

  • If the current tab can go back, navigate back.
  • If it cannot go back:
    • close the current tab by default
    • or, when configured, only close tabs that were opened from another tab
  • If the current tab is the last tab in the window, close the window instead.

smart-forward

  • If the current tab can go forward, navigate forward.
  • If it cannot go forward:
    • open a blank tab by default
    • or do nothing when the fallback is disabled

Popup

The popup provides:

  • current platform display
  • resolved shortcut display from chrome.commands.getAll()
  • manual Smart Back / Smart Forward buttons
  • settings for:
    • closePolicy: always-close or opener-only
    • forwardFallback: open-blank-tab or no-op
  • latest recorded action result

Current implementation scope

Implemented:

  • native Chrome Extension MV3 structure
  • background service worker
  • popup UI with settings and diagnostics
  • storage-backed settings and last action state
  • opener tab tracking via webNavigation and openerTabId
  • history boundary handling for tab close / window close / blank tab fallback
  • self-contained chrome.scripting.executeScript({ func }) navigation probing
  • unit tests for navigation planning logic

Not implemented:

  • options page
  • release packaging workflow
  • extension store publishing metadata
  • a fully reliable solution for macOS native text-editing shortcuts inside inputs

Platform assumptions

Current command suggestions in manifest.json:

  • macOS:
    • smart-back: Command+Left
    • smart-forward: Command+Right
  • Windows/Linux:
    • smart-back: Alt+Left
    • smart-forward: Alt+Right

These are only suggested bindings. Chrome may still prioritize browser or system shortcuts over extension commands in some cases.

Project structure

src/
  background/     background service worker
  lib/            shared logic for storage, navigation, planner, opener tracking
  popup/          popup HTML and TypeScript
  types/          shared app types
  manifest.json   MV3 manifest source
tests/
  *.spec.ts       Vitest unit tests
docs/
  known-issues.md current product/technical limitations

Development

Install dependencies:

pnpm install

Run checks:

pnpm typecheck
pnpm test
pnpm build

Watch build output during development:

pnpm dev

The production-ready unpacked extension output is written to dist/.

Load in Chrome

  1. Run pnpm build.
  2. Open chrome://extensions.
  3. Enable Developer mode.
  4. Choose Load unpacked.
  5. Select the dist/ directory.

After reloading the extension, validate both popup actions and keyboard shortcuts. The popup is the easiest place to confirm whether the core logic is working independently of shortcut routing behavior.

Manual validation checklist

  • A normal page with back history:
    • smart-back navigates back
  • A normal page without back history:
    • smart-back closes the tab
  • A window with a single remaining tab:
    • smart-back closes the whole window
  • A page with forward history:
    • smart-forward navigates forward
  • A page without forward history:
    • smart-forward opens about:blank by default
  • Popup setting changes:
    • closePolicy and forwardFallback persist across popup reopen
  • Restricted pages:
    • unsupported pages should not crash the extension

Known limitations

  • chrome.scripting.executeScript cannot run on all page types, such as Chrome internal pages.
  • Shortcut interception is ultimately constrained by Chrome and the host OS.
  • On macOS, using Command+Left / Command+Right conflicts with native text-editing expectations in focused inputs.

See docs/known-issues.md for the current conclusion on that last point.

About

Smart navigation at Chrome history boundaries.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors