@sv443-network/userutils 9.0.4 → 9.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/README-summary.md +38 -16
- package/README.md +25 -7
- package/dist/index.cjs +157 -58
- package/dist/index.global.js +159 -60
- package/dist/index.js +148 -59
- package/dist/lib/DataStoreSerializer.d.ts +16 -6
- package/dist/lib/dom.d.ts +19 -0
- package/dist/lib/errors.d.ts +21 -0
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/math.d.ts +52 -2
- package/dist/lib/misc.d.ts +22 -7
- package/dist/lib/translation.d.ts +23 -16
- package/dist/lib/types.d.ts +8 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# @sv443-network/userutils
|
|
2
2
|
|
|
3
|
+
## 9.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 905fea4: Added function `isDomLoaded()` to check if the DOM is queryable, regardless of `@run-at` setting
|
|
8
|
+
- 4264154: Added parameter `withDecimals` to `digitCount()` (true by default)
|
|
9
|
+
- 4264154: Added function `roundFixed()` to round a floating-point number to the given amount of decimals. Can also round to the given power of 10.
|
|
10
|
+
- 7e492cf: Added `probeElementStyle()` to probe the computed style of a temporary element, allowing to resolve CSS variables and default style values, etc.
|
|
11
|
+
- 905fea4: Added function `onDomLoad()` to call a callback and/or resolve a Promise when the DOM is loaded, even retroactively
|
|
12
|
+
- 4264154: Added function `bitSetHas()` to check if a given value is present in a [bitset](https://www.geeksforgeeks.org/cpp-bitset-and-its-application/)
|
|
13
|
+
- bf55335: Replaced a bunch of generic `Error`s with the new custom error class instances
|
|
14
|
+
- bf55335: Added custom error classes `ChecksumMismatchError`, `DataMigrationError` and `PlatformError`, extending from the base class `UUError`
|
|
15
|
+
The base class has the additional property `date` which is the time of the error creation
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- 157dacb: Fixed example code in tsdoc comments of translation functions
|
|
20
|
+
- 4264154: Fixed `digitCount()` not counting decimals by default
|
|
21
|
+
|
|
22
|
+
## 9.1.0
|
|
23
|
+
|
|
24
|
+
### Minor Changes
|
|
25
|
+
|
|
26
|
+
- eb20132: Added the type `ListWithLength` to represent an array or object with a numeric `length`, `count` or `size` property.
|
|
27
|
+
- eb20132: Added `autoPlural()` support for generic objects with a numeric `length`, `count` or `size` property.
|
|
28
|
+
- c9b13d8: Added `signal: AbortSignal` and `rejectOnAbort: boolean` params to `pauseFor()` to allow for cutting the pause short
|
|
29
|
+
- c66324b: Support for words with `-y`/`-ies` extension in `autoPlural()`
|
|
30
|
+
- c9b13d8: Added `getListLength()` function to resolve a value of the new `ListWithLength` type
|
|
31
|
+
- c13e890: `autoPlural()` now defaults `pluralType` to `"auto"` and `num` to 2 if `pluralType` is invalid or `num` resolves to NaN
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- 3f86215: Fixed fetchAdvanced error "'abort' called on an object that does not implement interface AbortController"
|
|
36
|
+
|
|
3
37
|
## 9.0.4
|
|
4
38
|
|
|
5
39
|
### Patch Changes
|
package/README-summary.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
## UserUtils
|
|
2
|
-
|
|
2
|
+
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.
|
|
3
3
|
Contains builtin TypeScript declarations. Supports ESM and CJS imports via a bundler and global declaration via `@require`
|
|
4
|
-
The library
|
|
4
|
+
The library works in any DOM environment with or without the [GreaseMonkey API](https://wiki.greasespot.net/Greasemonkey_Manual:API), but some features will be unavailable or limited.
|
|
5
5
|
|
|
6
6
|
You may want to check out my [template for userscripts in TypeScript](https://github.com/Sv443/Userscript.ts) that you can use to get started quickly. It also includes this library by default.
|
|
7
7
|
|
|
@@ -36,6 +36,8 @@ View the documentation of previous major releases:
|
|
|
36
36
|
- **DOM:**
|
|
37
37
|
- [`SelectorObserver`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#selectorobserver) - class that manages listeners that are called when selectors are found in the DOM
|
|
38
38
|
- [`getUnsafeWindow()`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#getunsafewindow) - get the unsafeWindow object or fall back to the regular window object
|
|
39
|
+
- [`isDomLoaded()`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#isdomloaded) - check if the DOM has finished loading and can be queried and modified
|
|
40
|
+
- [`onDomLoad()`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#ondomload) - run a function or pause async execution until the DOM has finished loading (or immediately if DOM is already loaded)
|
|
39
41
|
- [`addParent()`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#addparent) - add a parent element around another element
|
|
40
42
|
- [`addGlobalStyle()`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#addglobalstyle) - add a global style to the page
|
|
41
43
|
- [`preloadImages()`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#preloadimages) - preload images into the browser cache for faster loading later on
|
|
@@ -46,11 +48,14 @@ View the documentation of previous major releases:
|
|
|
46
48
|
- [`observeElementProp()`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#observeelementprop) - observe changes to an element's property that can't be observed with MutationObserver
|
|
47
49
|
- [`getSiblingsFrame()`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#getsiblingsframe) - returns a frame of an element's siblings, with a given alignment and size
|
|
48
50
|
- [`setInnerHtmlUnsafe()`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#setinnerhtmlunsafe) - set the innerHTML of an element using a [Trusted Types policy](https://developer.mozilla.org/en-US/docs/Web/API/Trusted_Types_API) without sanitizing or escaping it
|
|
51
|
+
- [`probeElementStyle()`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#probeelementstyle) - probe the computed style of a temporary element (get default font size, resolve CSS variables, etc.)
|
|
49
52
|
- **Math:**
|
|
50
53
|
- [`clamp()`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#clamp) - constrain a number between a min and max value
|
|
51
54
|
- [`mapRange()`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#maprange) - map a number from one range to the same spot in another range
|
|
52
55
|
- [`randRange()`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#randrange) - generate a random number between a min and max boundary
|
|
53
56
|
- [`digitCount()`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#digitcount) - calculate the amount of digits in a number
|
|
57
|
+
- [`roundFixed()`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#roundfixed) - round a floating-point number at the given amount of decimals, or to the given power of 10
|
|
58
|
+
- [`bitSetHas()`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#bitsethas) - check if a bit is set in a [bitset](https://www.geeksforgeeks.org/cpp-bitset-and-its-application/)
|
|
54
59
|
- **Misc:**
|
|
55
60
|
- [`DataStore`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#datastore) - class that manages a hybrid sync & async persistent JSON database, including data migration
|
|
56
61
|
- [`DataStoreSerializer`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#datastoreserializer) - class for importing & exporting data of multiple DataStore instances, including compression, checksumming and running migrations
|
|
@@ -66,22 +71,27 @@ View the documentation of previous major releases:
|
|
|
66
71
|
- [`decompress()`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#decompress) - decompress a previously compressed string
|
|
67
72
|
- [`computeHash()`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#computehash) - compute the hash / checksum of a string or ArrayBuffer
|
|
68
73
|
- [`randomId()`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#randomid) - generate a random ID of a given length and radix
|
|
74
|
+
- [`consumeGen()`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#consumegen) - consumes a ValueGen and returns the value
|
|
75
|
+
- [`consumeStringGen()`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#consumestringgen) - consumes a StringGen and returns the string
|
|
76
|
+
- [`getListLength()`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#getlistlength) - get the length of any object with a numeric `length`, `count` or `size` property
|
|
69
77
|
- **Arrays:**
|
|
70
78
|
- [`randomItem()`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#randomitem) - returns a random item from an array
|
|
71
79
|
- [`randomItemIndex()`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#randomitemindex) - returns a tuple of a random item and its index from an array
|
|
72
80
|
- [`takeRandomItem()`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#takerandomitem) - returns a random item from an array and mutates it to remove the item
|
|
73
81
|
- [`randomizeArray()`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#randomizearray) - returns a copy of the array with its items in a random order
|
|
74
82
|
- **Translation:**
|
|
75
|
-
- [`tr()`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#
|
|
76
|
-
- [`tr.
|
|
77
|
-
- [`tr.
|
|
78
|
-
- [`tr.
|
|
79
|
-
- [`tr.
|
|
80
|
-
- [`tr.
|
|
81
|
-
- [`tr.
|
|
82
|
-
- [`tr.
|
|
83
|
-
- [`tr.addTransform()`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#traddtransform) -
|
|
84
|
-
- [`tr.deleteTransform()`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#trdeletetransform) -
|
|
83
|
+
- [`tr.for()`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#trfor) - translates a key for the specified language
|
|
84
|
+
- [`tr.use()`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#truse) - creates a translation function for the specified language
|
|
85
|
+
- [`tr.hasKey()`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#trhaskey) - checks if a key exists in the given language
|
|
86
|
+
- [`tr.addTranslations()`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#traddtranslations) - add a flat or recursive translation object for a language
|
|
87
|
+
- [`tr.getTranslations()`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#trgettranslations) - returns the translation object for a language
|
|
88
|
+
- [`tr.deleteTranslations()`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#trdeletetranslations) - delete the translation object for a language
|
|
89
|
+
- [`tr.setFallbackLanguage()`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#trsetfallbacklanguage) - set the fallback language used when a key is not found in the given language
|
|
90
|
+
- [`tr.getFallbackLanguage()`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#trgetfallbacklanguage) - returns the fallback language
|
|
91
|
+
- [`tr.addTransform()`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#traddtransform) - adds a transform function to the translation system for custom argument insertion and much more
|
|
92
|
+
- [`tr.deleteTransform()`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#trdeletetransform) - removes a transform function
|
|
93
|
+
- [`tr.transforms`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#trtransforms) - predefined transform functions for quickly adding custom argument insertion
|
|
94
|
+
- [`TrKeys`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#trkeys) - generic type that extracts all keys from a flat or recursive translation object into a union
|
|
85
95
|
- **Colors:**
|
|
86
96
|
- [`hexToRgb()`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#hextorgb) - convert a hex color string to an RGB or RGBA value tuple
|
|
87
97
|
- [`rgbToHex()`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#rgbtohex) - convert RGB or RGBA values to a hex color string
|
|
@@ -95,6 +105,12 @@ View the documentation of previous major releases:
|
|
|
95
105
|
- [`Prettify`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#prettify) - expands a complex type into a more readable format while keeping functionality the same
|
|
96
106
|
- [`ValueGen`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#valuegen) - a "generator" value that allows for super flexible value typing and declaration
|
|
97
107
|
- [`StringGen`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#stringgen) - a "generator" string that allows for super flexible string typing and declaration, including enhanced support for unions
|
|
108
|
+
- [`ListWithLength`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#listwithlength) - represents an array or object with a numeric `length`, `count` or `size` property
|
|
109
|
+
- **Custom Error classes:**
|
|
110
|
+
- [`UUError`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#uuerror) - base class for all custom UserUtils errors - has a custom `date` prop set to the time of creation
|
|
111
|
+
- [`ChecksumMismatchError`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#checksummismatcherror) - thrown when a string of data doesn't match its checksum
|
|
112
|
+
- [`DataMigrationError`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#datamigrationerror) - thrown when a data migration fails
|
|
113
|
+
- [`PlatformError`](https://github.com/Sv443-Network/UserUtils/blob/main/docs.md#platformerror) - thrown when a function is called in an unsupported environment
|
|
98
114
|
|
|
99
115
|
<br><br>
|
|
100
116
|
|
|
@@ -138,9 +154,15 @@ Shameless plug: I made a [template for userscripts in TypeScript](https://github
|
|
|
138
154
|
// @require https://update.greasyfork.org/scripts/472956/UserUtils.js
|
|
139
155
|
// @require https://openuserjs.org/src/libs/Sv443/UserUtils.js
|
|
140
156
|
```
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
157
|
+
|
|
158
|
+
- 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](https://github.com/Sv443-Network/UserUtils/releases) to include in your project or add one of the following tags to the <head>:
|
|
159
|
+
```html
|
|
160
|
+
<script src="https://cdn.jsdelivr.net/npm/@sv443-network/userutils@INSERT_VERSION/dist/index.global.js"></script>
|
|
161
|
+
<script src="https://unpkg.com/@sv443-network/userutils@INSERT_VERSION/dist/index.global.js"></script>
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
> **Note:**
|
|
165
|
+
> 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.](https://greasyfork.org/scripts/472956-userutils)
|
|
144
166
|
|
|
145
167
|
<br>
|
|
146
168
|
|
|
@@ -156,7 +178,7 @@ Shameless plug: I made a [template for userscripts in TypeScript](https://github
|
|
|
156
178
|
|
|
157
179
|
<br>
|
|
158
180
|
|
|
159
|
-
- 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
|
|
181
|
+
- 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:
|
|
160
182
|
```ts
|
|
161
183
|
declare const UserUtils: typeof import("@sv443-network/userutils");
|
|
162
184
|
|
package/README.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
<!-- #region Description -->
|
|
4
4
|
## UserUtils
|
|
5
|
-
|
|
5
|
+
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.
|
|
6
6
|
Contains builtin TypeScript declarations. Supports ESM and CJS imports via a bundler and global declaration via `@require`
|
|
7
|
-
The library
|
|
7
|
+
The library works in any DOM environment with or without the [GreaseMonkey API](https://wiki.greasespot.net/Greasemonkey_Manual:API), but some features will be unavailable or limited.
|
|
8
8
|
|
|
9
9
|
You may want to check out my [template for userscripts in TypeScript](https://github.com/Sv443/Userscript.ts) that you can use to get started quickly. It also includes this library by default.
|
|
10
10
|
If you like using this library, please consider [supporting the development ❤️](https://github.com/sponsors/Sv443)
|
|
@@ -39,6 +39,8 @@ View the documentation of previous major releases:
|
|
|
39
39
|
- [**DOM:**](./docs.md#dom)
|
|
40
40
|
- [`SelectorObserver`](./docs.md#selectorobserver) - class that manages listeners that are called when selectors are found in the DOM
|
|
41
41
|
- [`getUnsafeWindow()`](./docs.md#getunsafewindow) - get the unsafeWindow object or fall back to the regular window object
|
|
42
|
+
- [`isDomLoaded()`](./docs.md#isdomloaded) - check if the DOM has finished loading and can be queried and modified
|
|
43
|
+
- [`onDomLoad()`](./docs.md#ondomload) - run a function or pause async execution until the DOM has finished loading (or immediately if DOM is already loaded)
|
|
42
44
|
- [`addParent()`](./docs.md#addparent) - add a parent element around another element
|
|
43
45
|
- [`addGlobalStyle()`](./docs.md#addglobalstyle) - add a global style to the page
|
|
44
46
|
- [`preloadImages()`](./docs.md#preloadimages) - preload images into the browser cache for faster loading later on
|
|
@@ -49,11 +51,14 @@ View the documentation of previous major releases:
|
|
|
49
51
|
- [`observeElementProp()`](./docs.md#observeelementprop) - observe changes to an element's property that can't be observed with MutationObserver
|
|
50
52
|
- [`getSiblingsFrame()`](./docs.md#getsiblingsframe) - returns a frame of an element's siblings, with a given alignment and size
|
|
51
53
|
- [`setInnerHtmlUnsafe()`](./docs.md#setinnerhtmlunsafe) - set the innerHTML of an element using a [Trusted Types policy](https://developer.mozilla.org/en-US/docs/Web/API/Trusted_Types_API) without sanitizing or escaping it
|
|
54
|
+
- [`probeElementStyle()`](./docs.md#probeelementstyle) - probe the computed style of a temporary element (get default font size, resolve CSS variables, etc.)
|
|
52
55
|
- [**Math:**](./docs.md#math)
|
|
53
56
|
- [`clamp()`](./docs.md#clamp) - constrain a number between a min and max value
|
|
54
57
|
- [`mapRange()`](./docs.md#maprange) - map a number from one range to the same spot in another range
|
|
55
58
|
- [`randRange()`](./docs.md#randrange) - generate a random number between a min and max boundary
|
|
56
59
|
- [`digitCount()`](./docs.md#digitcount) - calculate the amount of digits in a number
|
|
60
|
+
- [`roundFixed()`](./docs.md#roundfixed) - round a floating-point number at the given amount of decimals, or to the given power of 10
|
|
61
|
+
- [`bitSetHas()`](./docs.md#bitsethas) - check if a bit is set in a [bitset](https://www.geeksforgeeks.org/cpp-bitset-and-its-application/)
|
|
57
62
|
- [**Misc:**](./docs.md#misc)
|
|
58
63
|
- [`DataStore`](./docs.md#datastore) - class that manages a hybrid sync & async persistent JSON database, including data migration
|
|
59
64
|
- [`DataStoreSerializer`](./docs.md#datastoreserializer) - class for importing & exporting data of multiple DataStore instances, including compression, checksumming and running migrations
|
|
@@ -71,6 +76,7 @@ View the documentation of previous major releases:
|
|
|
71
76
|
- [`randomId()`](./docs.md#randomid) - generate a random ID of a given length and radix
|
|
72
77
|
- [`consumeGen()`](./docs.md#consumegen) - consumes a ValueGen and returns the value
|
|
73
78
|
- [`consumeStringGen()`](./docs.md#consumestringgen) - consumes a StringGen and returns the string
|
|
79
|
+
- [`getListLength()`](./docs.md#getlistlength) - get the length of any object with a numeric `length`, `count` or `size` property
|
|
74
80
|
- [**Arrays:**](./docs.md#arrays)
|
|
75
81
|
- [`randomItem()`](./docs.md#randomitem) - returns a random item from an array
|
|
76
82
|
- [`randomItemIndex()`](./docs.md#randomitemindex) - returns a tuple of a random item and its index from an array
|
|
@@ -102,6 +108,12 @@ View the documentation of previous major releases:
|
|
|
102
108
|
- [`Prettify`](./docs.md#prettify) - expands a complex type into a more readable format while keeping functionality the same
|
|
103
109
|
- [`ValueGen`](./docs.md#valuegen) - a "generator" value that allows for super flexible value typing and declaration
|
|
104
110
|
- [`StringGen`](./docs.md#stringgen) - a "generator" string that allows for super flexible string typing and declaration, including enhanced support for unions
|
|
111
|
+
- [`ListWithLength`](./docs.md#listwithlength) - represents an array or object with a numeric `length`, `count` or `size` property
|
|
112
|
+
- [**Custom Error classes**](./docs.md#error-classes)
|
|
113
|
+
- [`UUError`](./docs.md#uuerror) - base class for all custom UserUtils errors - has a custom `date` prop set to the time of creation
|
|
114
|
+
- [`ChecksumMismatchError`](./docs.md#checksummismatcherror) - thrown when a string of data doesn't match its checksum
|
|
115
|
+
- [`DataMigrationError`](./docs.md#datamigrationerror) - thrown when a data migration fails
|
|
116
|
+
- [`PlatformError`](./docs.md#platformerror) - thrown when a function is called in an unsupported environment
|
|
105
117
|
|
|
106
118
|
<br><br>
|
|
107
119
|
|
|
@@ -132,21 +144,27 @@ Shameless plug: I made a [template for userscripts in TypeScript](https://github
|
|
|
132
144
|
|
|
133
145
|
<br>
|
|
134
146
|
|
|
135
|
-
- If you are not using a bundler, want to reduce the size of your
|
|
147
|
+
- If you are not using a bundler, want to reduce the size of your script, 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:
|
|
136
148
|
|
|
137
149
|
Versioned (recommended):
|
|
138
150
|
```
|
|
139
151
|
// @require https://cdn.jsdelivr.net/npm/@sv443-network/userutils@INSERT_VERSION/dist/index.global.js
|
|
140
152
|
// @require https://unpkg.com/@sv443-network/userutils@INSERT_VERSION/dist/index.global.js
|
|
141
153
|
```
|
|
142
|
-
Non-versioned (not recommended because auto-
|
|
154
|
+
Non-versioned (not recommended because it auto-updates):
|
|
143
155
|
```
|
|
144
156
|
// @require https://update.greasyfork.org/scripts/472956/UserUtils.js
|
|
145
157
|
// @require https://openuserjs.org/src/libs/Sv443/UserUtils.js
|
|
146
158
|
```
|
|
147
|
-
|
|
159
|
+
|
|
160
|
+
- 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](https://github.com/Sv443-Network/UserUtils/releases) to include in your project or add one of the following tags to the <head>:
|
|
161
|
+
```html
|
|
162
|
+
<script src="https://cdn.jsdelivr.net/npm/@sv443-network/userutils@INSERT_VERSION/dist/index.global.js"></script>
|
|
163
|
+
<script src="https://unpkg.com/@sv443-network/userutils@INSERT_VERSION/dist/index.global.js"></script>
|
|
164
|
+
```
|
|
165
|
+
|
|
148
166
|
> [!NOTE]
|
|
149
|
-
> In order for your
|
|
167
|
+
> In order for your script 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.](https://greasyfork.org/scripts/472956-userutils)
|
|
150
168
|
|
|
151
169
|
<br>
|
|
152
170
|
|
|
@@ -163,7 +181,7 @@ Shameless plug: I made a [template for userscripts in TypeScript](https://github
|
|
|
163
181
|
|
|
164
182
|
<br>
|
|
165
183
|
|
|
166
|
-
- 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
|
|
184
|
+
- 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:
|
|
167
185
|
|
|
168
186
|
```ts
|
|
169
187
|
declare const UserUtils: typeof import("@sv443-network/userutils");
|