mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-16 23:42:39 +01:00
Updated set-constant documentation
parent
5b88834653
commit
b514a566b6
@ -950,27 +950,44 @@ Parameters:
|
||||
- `''` - empty string<sup>[2019-01-06](https://github.com/uBlockOrigin/uAssets/commit/5051610f0e2374955a03c54be42bbbe9115f05c7#diff-8809d5783978a0b5b88f93d7dab99de0R2132)</sup>
|
||||
- `[]` - empty array<sup>[1.36](https://github.com/gorhill/uBlock/commit/ce801b952b5777775385efc00479405af54edbc9)</sup>
|
||||
- `{}` - empty object<sup>[1.36](https://github.com/gorhill/uBlock/commit/ce801b952b5777775385efc00479405af54edbc9)</sup>
|
||||
|
||||
<details>
|
||||
<summary> ● optional (deprecated in favor of "runAt" token)</summary>
|
||||
|
||||
▬▬► 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 ◄▬▬
|
||||
|
||||
</details>
|
||||
|
||||
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-)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user