Skip to content

Commit

Permalink
docs: edit readmes again
Browse files Browse the repository at this point in the history
  • Loading branch information
Sv443 committed Nov 12, 2024
1 parent 22f214e commit 561f40a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 10 deletions.
29 changes: 23 additions & 6 deletions README-summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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)
Expand All @@ -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"
}
```
22 changes: 18 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,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";

Expand All @@ -115,7 +116,7 @@ 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:
- 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):
```
Expand Down Expand Up @@ -145,11 +146,24 @@ 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"
}
```

Expand Down

0 comments on commit 561f40a

Please sign in to comment.