Mirror of UserUtils' source code https://github.com/Sv443-Network/UserUtils
|
před 1 rokem | |
---|---|---|
.changeset | před 1 rokem | |
.github | před 1 rokem | |
lib | před 1 rokem | |
.eslintrc.cjs | před 1 rokem | |
.gitignore | před 1 rokem | |
.npmignore | před 1 rokem | |
CHANGELOG.md | před 1 rokem | |
LICENSE.txt | před 1 rokem | |
README.greasyfork.md | před 1 rokem | |
README.md | před 1 rokem | |
package-lock.json | před 1 rokem | |
package.json | před 1 rokem | |
tsconfig.json | před 1 rokem |
Library with various utilities for userscripts - register listeners for when CSS selectors exist, intercept events, modify the DOM more easily and more.
Contains builtin TypeScript declarations. Webpack compatible and supports ESM and CJS.
Licensed under the MIT license.
If you like using this library, please consider supporting the development ❤️
onSelector()
addEventListener()
on any given EventTarget objectaddEventListener()
on the window objectIf you are using a bundler like webpack, you can install this package using npm:
npm i @sv443-network/userutils
Then, import it in your script as usual:
import { addGlobalStyle } from "@sv443-network/userutils";
// or
import * as userUtils from "@sv443-network/userutils";
Shameless plug: I also have a webpack-based template for userscripts in TypeScript that you can use to get started quickly.
If you are not using a bundler, you can include the latest release from GreasyFork by adding this directive to the userscript header:
// @require https://greasyfork.org/scripts/472956-userutils/code/UserUtils.js
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