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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@yiero/vite-plugin-scriptcat-script-push

v1.0.0

Published

A vite plugin to push ScriptCat scripts to browsers using ScriptCat extension.

Readme

Vite Plugin ScriptCat Script Push

English / 中文

Features

Automatically push rebuilt JavaScript bundles to the ScriptCat extension via WebSocket during development. Enables instant script updates without manual reloading or reinstallation.

The updated script still requires refreshing the page to be reloaded into the page.

Installation

npm install @yiero/vite-plugin-scriptcat-script-push -D
# or
yarn add @yiero/vite-plugin-scriptcat-script-push -D
# or
pnpm add @yiero/vite-plugin-scriptcat-script-push -D

Configuration

| Parameter | Type | Description | Default | | --------- | -------- | ---------------------------------------------- | --------- | | port | number | Port number for the WebSocket server | 8642 | | match | RegExp | Regular expression to match files to broadcast | /\.js$/ |

Usage

Note: Only one ws server can be running at a time.

Install the plugin

Add the plugin in vite.config.js / vite.config.ts:

Basic Usage

import { defineConfig } from 'vite'
import scriptPushPlugin from '@yiero/vite-plugin-scriptcat-script-push'

export default defineConfig({
  plugins: [
    // Other plugins...
    
    // Automatically push rebuilt scripts to ScriptCat
    scriptPushPlugin()
  ],
})

Advanced Usage

import { defineConfig } from 'vite'
import scriptPushPlugin from '@yiero/vite-plugin-scriptcat-script-push'

export default defineConfig({
  plugins: [
    // Push files with .user.js suffix on a custom port
    scriptPushPlugin({
      // Custom port
      port: 8642,
      // Custom script suffix to push
      match: /\.user\.js$/
    })
  ],
})

Connect to the server

  1. Open Browser - ScriptCat Script List interface
  2. Click the Tools menu on the left
  3. Find the Development Debugging section
  4. Find VSCode URL, click the Connect button below
  5. If using a custom port, modify the value of ws://localhost:8642 to the corresponding port number: ws://localhost:<port>.

image-20251214021257327


Develop the script

  1. Build the script in watch mode: vite build --watch.

If the script is successfully installed, it will show that the ws server has started below watching for file changes...:

watching for file changes...
[ScriptCat] WS server started on port 8642
  1. Follow the steps in Connect to the server to connect to the ws server.

If ScriptCat successfully connects to the ws server, it will show in the terminal:

[ScriptCat] client-1 connected
  1. When you modify the script source file, triggering the vite rebuild process, the plugin will automatically push the completed bundled script to all connected clients.

If the script broadcast is successful, it will show in the terminal:

[ScriptCat] broadcast to client-1: <local file path>

How It Works

The plugin automatically performs the following operations:

  1. Creates a WebSocket server on the specified port during Vite build
  2. Checks if the port is available before starting the server
  3. Maintains connections with all active clients
  4. When Vite rebuilds and writes the bundle:
    • Filters files based on the matching pattern
    • Converts file paths to the correct URL
    • Broadcasts the updated script content to all connected clients
  5. Sends a ping message every 30 seconds to keep the connection alive

Contribution Guide

Please submit issues or PRs via GitHub.

License

GPL-3 © AliubYiero