MCPcopy Index your code
hub / github.com/SimonAlling/userscripter

github.com/SimonAlling/userscripter @v7.0.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v7.0.0 ↗ · + Follow
73 symbols 156 edges 34 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Userscripter

Create userscripts in a breeze!

  • Safe, declarative DOM operations and stylesheets
  • Straightforward preference management
  • TypeScript constants in SASS code
  • Build as native browser extension (optional)
  • Metadata validation
  • Static typing

Getting started

Prerequisites

Create a new userscript

cd path/to/my-new-userscript
npx tiged@2.12.7 https://github.com/SimonAlling/userscripter/bootstrap#master

If everything went well, an src directory should have been created, along with some other files like package.json and webpack.config.ts. You should now be able to build the userscript:

npm ci
npm run build

The compiled userscript should be saved as dist/bootstrapped-userscript.user.js.

Install the userscript

Userscripts are usually installed through a browser extension, for example Violentmonkey (Firefox, Chrome). Please refer to the documentation for the one you use:

Check that the userscript works

Go to http://example.com. If you haven't modified anything, you should see a green background and [Bootstrapped Userscript] Bootstrapped Userscript 0.1.0 in the developer console.

How to write a userscript

A userscript typically consists primarily of DOM operations and stylesheets. It can also have user-facing preferences. Check out these repositories for examples:

Build options

The buildConfig property of the object passed to createWebpackConfig controls how the userscript is built (see e.g. webpack.config.ts in the example repo).

You can override certain options on the command line using environment variables:

USERSCRIPTER_MODE=production USERSCRIPTER_VERBOSE=true npm run build

(With USERSCRIPTER_VERBOSE=true, all available environment variables are listed.)

You can also customize the object returned from createWebpackConfig in webpack.config.ts:

import { createWebpackConfig } from 'userscripter/build-time';

const webpackConfig = createWebpackConfig({
    // …
});

export default {
    ...webpackConfig,
    resolve: {
        ...webpackConfig.resolve,
        alias: {
            ...webpackConfig.resolve?.alias,
            "react": "preact/compat", // Adding an alias here.
        },
    },
    // Other properties (e.g. 'stats') could be added/overridden here.
};

Such customizations will take precedence over environment variables.

Native browser extension

To create a native browser extension from your userscript, include a manifest in the object passed to createWebpackConfig (example). manifest.json will then be created alongside the compiled .user.js file. You can then use web-ext to build the native extension:

npm install -g web-ext
cd dist
web-ext build

Core symbols most depended-on inside this repo

getGlobalFrom
called by 6
src/build-time/internal/sass.ts
withDartSassEncodedParameters
called by 6
src/build-time/internal/sass.ts
operation
called by 5
src/run-time/operations.ts
distFileName
called by 4
src/build-time/internal/configuration.ts
webpackifyMessage
called by 4
src/build-time/internal/messages.ts
envVarName
called by 3
src/build-time/internal/configuration.ts
resolveIn
called by 3
src/build-time/internal/webpack.ts
filenameExtensionRegex
called by 3
src/build-time/internal/webpack.ts

Shape

Function 65
Class 4
Method 3
Enum 1

Languages

TypeScript100%

Modules by API surface

src/build-time/internal/messages.ts9 symbols
src/build-time/internal/webpack.ts7 symbols
src/run-time/operations.ts6 symbols
src/run-time/log.ts6 symbols
src/build-time/internal/configuration.ts6 symbols
src/build-time/internal/webpack-plugin.ts5 symbols
src/build-time/internal/sass.ts5 symbols
src/run-time/preferences.ts4 symbols
src/run-time/environment.ts4 symbols
src/run-time/stylesheets.ts3 symbols
src/run-time/errors.ts3 symbols
src/build-time/internal/validation.ts3 symbols

For agents

$ claude mcp add userscripter \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact