From b514a566b61647af6500d7b8804d51df4b9f6315 Mon Sep 17 00:00:00 2001
From: garry-ut99 <72945564+garry-ut99@users.noreply.github.com>
Date: Mon, 1 Jul 2024 19:27:38 +0000
Subject: [PATCH] Updated set-constant documentation
---
Resources-Library.md | 37 +++++++++++++++++++++++++++----------
1 file changed, 27 insertions(+), 10 deletions(-)
diff --git a/Resources-Library.md b/Resources-Library.md
index 9b4763c..c3ccd62 100644
--- a/Resources-Library.md
+++ b/Resources-Library.md
@@ -950,27 +950,44 @@ Parameters:
- `''` - empty string[2019-01-06](https://github.com/uBlockOrigin/uAssets/commit/5051610f0e2374955a03c54be42bbbe9115f05c7#diff-8809d5783978a0b5b88f93d7dab99de0R2132)
- `[]` - empty array[1.36](https://github.com/gorhill/uBlock/commit/ce801b952b5777775385efc00479405af54edbc9)
- `{}` - empty object[1.36](https://github.com/gorhill/uBlock/commit/ce801b952b5777775385efc00479405af54edbc9)
- - optional, to defer execution of `set-constant`, possible values:
+
+
+ ● optional (deprecated in favor of "runAt" token)
+
+▬▬► SPOILER START ◄▬▬
+- optional, to defer execution of `set-constant`, possible values:
- _not present_: execute immediately
- 1: execute immediately
- `interactive`, `end`, `2`: set the constant when the event `DOMContentInteractive` is fired
- `complete`, `idle`, `3`: set the constant when the event `load` is fired
+▬▬► SPOILER END ◄▬▬
+
+
+
Tokens:
- - New in [1.49.3b4](https://github.com/gorhill/uBlock/commit/e1500ee88d2524da0c93e85b8855d0671a3c6cdb), solves [uBlockOrigin/uAssets#7320](https://github.com/uBlockOrigin/uAssets/issues/7320):
- - `interactive`, `end`, `2`: set the constant when the event `DOMContentLoaded` is fired
- - `complete`, `idle`, `3`: set the constant when the event `load` is fired
- - New in [1.49.3b13](https://github.com/gorhill/uBlock/releases/tag/1.49.3b13), solves [uBlockOrigin/uBlock-issues#2615](https://github.com/uBlockOrigin/uBlock-issues/issues/2615):
- - `asFunction`: the constant will be a function returning the specified value
- - `asCallback`: the constant will be a function returning a function returning the specified value
- - `asResolved`: the constant will be a promise resolving to the specified value
- - `asRejected`: the constant will be a promise failing with the specified value.
+ - "runAt": when this parameter is present, uBO will take it into account to possibly defer execution of the scriptlet
+new in [1.49.3b4](https://github.com/gorhill/uBlock/commit/e1500ee88d2524da0c93e85b8855d0671a3c6cdb), updated in [1.51.1rc0](https://github.com/gorhill/uBlock/commit/f407c28a00338032ff08a03d9f19a2487af814ff), solves [uBlockOrigin/uAssets#7320](https://github.com/uBlockOrigin/uAssets/issues/7320):
+ - "runAt" not present: execute immediately
+ - `loading` or `1` : execute immediately
+ - `interactive` or `end` or `2`: set the constant when the event `DOMContentLoaded` is fired
+ - `complete` or `idle` or `3`: set the constant when the event `load` is fired
+ - "as": when this parameter is present, uBO will take it into account how the values will be returned
+new in [1.49.3b13](https://github.com/gorhill/uBlock/releases/tag/1.49.3b13), updated in [1.51.1rc0](https://github.com/gorhill/uBlock/commit/f407c28a00338032ff08a03d9f19a2487af814ff), solves [uBlockOrigin/uBlock-issues#2615](https://github.com/uBlockOrigin/uBlock-issues/issues/2615):
+ - `function`: the constant will be a function returning the specified value (~~`asFunction`~~ is deprecated)
+ - `callback`: the constant will be a function returning a function returning the specified value (~~`asCallback`~~ is deprecated)
+ - `resolved`: the constant will be a promise resolving to the specified value (~~`asResolved`~~ is deprecated)
+ - `rejected`: the constant will be a promise failing with the specified value (~~`asRejected`~~ is deprecated)
+- "stack": considered to be implemented in the future, ideally, AdGuard would support its `stack` parameter as a
+vararg, to be discussed,
+issue to be solved: https://github.com/uBlockOrigin/uBlock-issues/issues/2783
Examples:
- `kompetent.de##+js(set, Object.keys, trueFunc)`
- `t-online.de##+js(set, abp, false)`
- `identi.li##+js(set, t_spoiler, 0)`
- - `joysound.com##+js(set, document.body.oncopy, null, 3)`
+ - ~~`joysound.com##+js(set, document.body.oncopy, null, 3)`~~ (deprecated)
+ - `joysound.com##+js(set, document.body.oncopy, null, runAt, 3)`
Also see: [trusted-set-constant](#trusted-set-constantjs-)