npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@lkd70/userscript-settings

v1.0.3

Published

A flexible and type-safe settings management system for UserScripts with a modern React-based UI

Readme

Build Status

UserScript Settings

A powerful and flexible settings management library for UserScripts, with a beautiful React-based UI.

Features

  • 🎨 Beautiful, modern UI with dark/light theme support
  • ⚡ Real-time setting updates
  • 🔒 Type-safe with TypeScript support
  • 🎯 Easy to integrate with any UserScript
  • 📱 Responsive design
  • ⌨️ Keyboard shortcuts
  • 🎯 Comprehensive documentation

Installation

As a UserScript

Add the following to your UserScript metadata:

// ==UserScript==
// @name         My UserScript
// @namespace    http://tampermonkey.net/
// @version      1.0.0
// @description  My awesome UserScript
// @author       Your Name
// @match        *://*/*
// @grant        none
// @require      https://unpkg.com/react@18/umd/react.production.min.js
// @require      https://unpkg.com/react-dom@18/umd/react-dom.production.min.js
// @require      https://raw.githubusercontent.com/yourusername/userscript-settings/main/dist/userscript-settings.user.js
// ==/UserScript==

Then in your UserScript code:

// Initialize settings
const settings = UserScriptSettings.initialize('my-script', '1.0.0');

// Define a setting
settings.defineSetting('refreshInterval', {
    type: UserScriptSettings.SettingType.NUMBER,
    defaultValue: 5000,
    description: 'How often to refresh the data (in milliseconds)',
    ui: {
        tab: 'general',
        group: 'basic',
        order: 1,
        options: {
            number: {
                min: 1000,
                max: 30000,
                step: 1000
            }
        }
    }
});

// Configure the UI
const uiConfig = {
    tabs: [
        { id: 'general', label: 'General', icon: '⚙️' }
    ],
    groups: [
        { id: 'basic', label: 'Basic Settings', tab: 'general' }
    ],
    theme: UserScriptSettings.DEFAULT_THEMES.light
};

// Render the settings UI
const container = document.createElement('div');
document.body.appendChild(container);
const root = ReactDOM.createRoot(container);
root.render(
    React.createElement(UserScriptSettings.SettingsUI, {
        settings: settings,
        config: uiConfig
    })
);

For detailed UserScript integration instructions, see our UserScript Guide.

As an NPM Package

npm install userscript-settings

Basic Usage

import { UserScriptSettings, SettingType, DEFAULT_THEMES } from 'userscript-settings';

// Initialize settings
const settings = UserScriptSettings.initialize('my-script', '1.0.0');

// Define a setting
settings.defineSetting('refreshInterval', {
    type: SettingType.NUMBER,
    defaultValue: 5000,
    description: 'How often to refresh the data (in milliseconds)',
    ui: {
        tab: 'general',
        group: 'basic',
        order: 1,
        options: {
            number: {
                min: 1000,
                max: 30000,
                step: 1000
            }
        }
    }
});

// Configure the UI
const uiConfig = {
    tabs: [
        { id: 'general', label: 'General', icon: '⚙️' }
    ],
    groups: [
        { id: 'basic', label: 'Basic Settings', tab: 'general' }
    ],
    theme: DEFAULT_THEMES.light
};

// Render the settings UI
const root = ReactDOM.createRoot(container);
root.render(
    React.createElement(SettingsUI, {
        settings: settings,
        config: uiConfig
    })
);

API Reference

Setting Types

  • SettingType.TEXT - Text input
  • SettingType.NUMBER - Number input
  • SettingType.BOOLEAN - Checkbox
  • SettingType.SELECT - Dropdown
  • SettingType.COLOR - Color picker
  • SettingType.SLIDER - Slider

Methods

  • initialize(namespace: string, version: string) - Initialize settings
  • defineSetting(key: string, config: SettingConfig) - Define a new setting
  • getSetting(key: string) - Get a setting value
  • setSetting(key: string, value: any) - Set a setting value
  • resetSetting(key: string) - Reset a setting to its default value
  • resetAllSettings() - Reset all settings to their default values
  • onSettingChange(key: string, callback: (newValue: any, oldValue: any) => void) - Listen for setting changes

UI Configuration

interface UIConfig {
    tabs: Array<{
        id: string;
        label: string;
        icon?: string;
    }>;
    groups: Array<{
        id: string;
        label: string;
        tab: string;
    }>;
    theme: Theme;
}

Theme Customization

The library comes with built-in light and dark themes, but you can customize them:

const customTheme = {
    ...DEFAULT_THEMES.light,
    colors: {
        ...DEFAULT_THEMES.light.colors,
        primary: '#FF0000', // Custom primary color
    }
};

Keyboard Shortcuts

  • Ctrl + , - Open/close settings
  • Esc - Close settings
  • Tab - Navigate between settings
  • Enter - Toggle boolean settings
  • Space - Toggle boolean settings

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.