Skip to content
violentmonkeyPublic

About

Add SPA support to your userscript.

Resources

Stars

16 stars

Watchers

1 watching

Forks

Repository files navigation

@violentmonkey/url

NPM License

Add SPA support to your userscript.

Usage

Importing

  1. Use in a userscript:

    // ...
    // @require https://cdn.jsdelivr.net/npm/@violentmonkey/url
    // ...
    
    const { onNavigate } = VM;
  2. Use as a module:

    $ yarn add @violentmonkey/url
    import { onNavigate } from "@violentmonkey/url";

Handling

function handleNavigate() {
  resetAllFeatures();
  if (window.location.pathname === "/foo") {
    enableFeatureFoo();
  } else if (window.location.pathname === "/bar") {
    enableFeatureBar();
  }
}

// Watch route change
VM.onNavigate(handleNavigate);

// Call it once for the initial state
handleNavigate();

About

Add SPA support to your userscript.

Resources

Stars

16 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages