UserUtils

General purpose DOM/GreaseMonkey library: register listeners for when CSS selectors exist, intercept events, create persistent & synchronous data stores, modify the DOM more easily and much more

Questo script non dovrebbe essere installato direttamente. È una libreria per altri script da includere con la chiave // @require https://update.greasyfork.org/scripts/472956/1752000/UserUtils.js

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

You will need to install an extension such as Tampermonkey to install this script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

Autore
Sv443
Versione
10.0.6
Creato il
12/08/2023
Aggiornato il
09/02/2026
Dimensione
107 KB
Licenza
MIT

UserUtils

General purpose DOM/GreaseMonkey library that allows you to register listeners for when CSS selectors exist, intercept events, create persistent & synchronous data stores, modify the DOM more easily and much more.
Contains builtin TypeScript declarations. Supports ESM and CJS imports via a bundler and global declaration via @require or <script>
The library works in any DOM environment with or without the GreaseMonkey API, but some features will be unavailable or limited.

You may want to check out my template for userscripts in TypeScript that you can use to get started quickly. It also includes this library by default.

If you like using this library, please consider supporting the development ❤️


Code coverage percentage badge Bundle size badge

Discord server badge Github stargazers badge Support development on Github Sponsors badge


> Full documentation on GitHub <


View the documentation of previous major versions:

v9.4.4v8.4.0v7.3.0v6.3.0v5.0.1v4.2.1v3.0.0v2.0.1v1.2.0v0.5.3


Feature Summary:



Installation:

Shameless plug: I made a template for userscripts in TypeScript that you can use to get started quickly. It also includes this library by default.

  • If you are using a bundler (like webpack, rollup, vite, etc.), you can install this package in one of the following ways:

    npm i @sv443-network/userutils
    pnpm i @sv443-network/userutils
    yarn add @sv443-network/userutils
    npx jsr install @sv443-network/userutils
    deno add jsr:@sv443-network/userutils
    

    Then import it in your script as usual:

    // on Node:
    import { addGlobalStyle } from "@sv443-network/userutils";
    
    // on Deno:
    import { addGlobalStyle } from "jsr:@sv443-network/userutils";
    
    // you can also import the entire library as an object (not recommended because of worse treeshaking support):
    import * as UserUtils from "@sv443-network/userutils";
    


  • If you are not using a bundler, want to reduce the size of your userscript, or declared the package as external in your bundler, you can include the latest release by adding one of these directives to the userscript header, depending on your preferred CDN:
    Versioned (recommended):

    // @require https://cdn.jsdelivr.net/npm/@sv443-network/userutils@INSERT_VERSION/dist/UserUtils.umd.js
    // @require https://unpkg.com/@sv443-network/userutils@INSERT_VERSION/dist/UserUtils.umd.js
    

    Non-versioned (not recommended because auto-updating):

    // @require https://update.greasyfork.org/scripts/472956/UserUtils.js
    // @require https://openuserjs.org/src/libs/Sv443/UserUtils.js
    
  • If you are using this library in a generic DOM environment without access to the GreaseMonkey API, either download the latest release from the releases page to include in your project or add one of the following tags to the <head>:

    <script src="https://cdn.jsdelivr.net/npm/@sv443-network/userutils@INSERT_VERSION/dist/UserUtils.umd.js"></script>
    <script src="https://unpkg.com/@sv443-network/userutils@INSERT_VERSION/dist/UserUtils.umd.js"></script>
    

Note:
In order for your userscript not to break on a major library update, use one the versioned URLs above after replacing INSERT_VERSION with the desired version (e.g. 8.3.2) or the versioned URL that's shown at the top of the GreasyFork page.


  • Then, access the functions on the global variable UserUtils:

    UserUtils.addGlobalStyle("body { background-color: red; }");
    
    // or using object destructuring:
    
    const { clamp } = UserUtils;
    console.log(clamp(1, 5, 10)); // 5
    


  • If you're using TypeScript and it complains about the missing global variable UserUtils, install the library using the package manager of your choice and add the following inside any .ts file that is included in the final build:

    declare const UserUtils: typeof import("@sv443-network/userutils");
    
    declare global {
        interface Window {
            UserUtils: typeof UserUtils;
        }
    }
    


  • If you're using a linter like ESLint, it might complain about the global variable UserUtils not being defined. To fix this, add the following to your ESLint configuration file:

    "globals": {
        "UserUtils": "readonly"
    }
    



License:

This library is licensed under the MIT License.
See the license file for details.




Made with ❤️ by Sv443
If you like this library, please consider supporting the development