@violentmonkey/url
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

@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();

Readme

Keywords

none

Package Sidebar

Install

npm i @violentmonkey/url

Weekly Downloads

3

Version

0.1.0

License

MIT

Unpacked Size

6.71 kB

Total Files

6

Last publish

Collaborators

  • vm-dev
  • gera2ld