|
@@ -100,7 +100,8 @@ Shameless plug: I made a [template for userscripts in TypeScript](https://github
|
|
|
npx jsr install @sv443-network/userutils
|
|
|
deno add jsr:@sv443-network/userutils
|
|
|
```
|
|
|
- Then, import it in your script as usual:
|
|
|
+ Then import it in your script as usual:
|
|
|
+
|
|
|
```ts
|
|
|
import { addGlobalStyle } from "@sv443-network/userutils";
|
|
|
|
|
@@ -112,17 +113,20 @@ Shameless plug: I made a [template for userscripts in TypeScript](https://github
|
|
|
|
|
|
<br>
|
|
|
|
|
|
-- If you are not using a bundler or want to reduce the size of your userscript, you can include the latest release by adding one of these directives to the userscript header, depending on your preferred CDN:
|
|
|
- Versioned (recommended):
|
|
|
+- 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/index.global.js
|
|
|
// @require https://unpkg.com/@sv443-network/userutils@INSERT_VERSION/dist/index.global.js
|
|
|
```
|
|
|
- Non-versioned (not recommended because auto-updating):
|
|
|
+ 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
|
|
|
```
|
|
|
+
|
|
|
> **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.](https://greasyfork.org/scripts/472956-userutils)
|
|
|
|
|
@@ -140,9 +144,22 @@ Shameless plug: I made a [template for userscripts in TypeScript](https://github
|
|
|
|
|
|
<br>
|
|
|
|
|
|
-- 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 a `.d.ts` file somewhere in your project:
|
|
|
+- 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 a `.d.ts` file somewhere in the directory (or a subdirectory) defined in your `tsconfig.json`'s `baseUrl` option or `include` array:
|
|
|
```ts
|
|
|
+ declare const UserUtils: typeof import("@sv443-network/userutils");
|
|
|
+
|
|
|
declare global {
|
|
|
- const UserUtils: typeof import("@sv443-network/userutils");
|
|
|
+ interface Window {
|
|
|
+ UserUtils: typeof UserUtils;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ```
|
|
|
+
|
|
|
+<br>
|
|
|
+
|
|
|
+- 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:
|
|
|
+ ```json
|
|
|
+ "globals": {
|
|
|
+ "UserUtils": "readonly"
|
|
|
}
|
|
|
```
|