Skip to content

Commit f57484b

Browse files
author
Atlassian Bamboo
committed
deploy: update docs for v2.4.3
1 parent 292bb04 commit f57484b

2 files changed

Lines changed: 147 additions & 26 deletions

File tree

wiki/about-scriptlets.md

Lines changed: 143 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ https://github.com/gorhill/uBlock/commit/c8de9041917b61035171e454df886706f27fc4f
667667
example.org#%#//scriptlet('evaldata-prune'[, propsToRemove [, obligatoryProps [, stack]]])
668668
```
669669

670-
- `propsToRemove` — optional, string of space-separated properties to remove
670+
- `propsToRemove` — optional, string of space-separated properties to remove.
671671
- `obligatoryProps` — optional, string of space-separated properties
672672
which must be all present for the pruning to occur
673673
- `stack` — optional, string or regular expression that must match the current function call stack trace;
@@ -1179,8 +1179,8 @@ example.org#%#//scriptlet('json-prune-fetch-response'[, propsToRemove[, obligato
11791179
if regular expression is invalid it will be skipped.
11801180
- `mode` — optional, syntax mode selector.
11811181
Supported values:
1182-
- `legacy` — force the existing legacy path syntax
1183-
- `jsonpath` — force JSONPath syntax
1182+
- `legacy` — force the existing legacy path syntax;
1183+
- `jsonpath` — force JSONPath syntax.
11841184
If omitted, the scriptlet detects JSONPath automatically for clearly JSONPath-shaped expressions.
11851185

11861186
> Note please that you can use wildcard `*` for chain property name,
@@ -1301,19 +1301,19 @@ example.org#%#//scriptlet('json-prune-xhr-response'[, propsToRemove[, obligatory
13011301
- `propsToRemove` — optional, string of space-separated properties to remove.
13021302
In `jsonpath` mode only single JSONPath prune expression is supported.
13031303
- `obligatoryProps` — optional, string of space-separated properties
1304-
which must be all present for the pruning to occur
1304+
which must be all present for the pruning to occur.
13051305
- `propsToMatch` — optional, string of space-separated properties to match for extra condition; possible props:
13061306
- string or regular expression for matching the URL passed to `XMLHttpRequest.open()` call;
1307-
- colon-separated pairs `name:value` where
1308-
- `name` — string or regular expression for matching XMLHttpRequest property name
1307+
- colon-separated pairs `name:value` where:
1308+
- `name` — string or regular expression for matching XMLHttpRequest property name;
13091309
- `value` — string or regular expression for matching the value of the option
1310-
passed to `XMLHttpRequest.open()` call
1310+
passed to `XMLHttpRequest.open()` call.
13111311
- `stack` — optional, string or regular expression that must match the current function call stack trace;
1312-
if regular expression is invalid it will be skipped
1312+
if regular expression is invalid it will be skipped.
13131313
- `mode` — optional, syntax mode selector.
13141314
Supported values:
1315-
- `legacy` — force the existing legacy path syntax
1316-
- `jsonpath` — force JSONPath syntax
1315+
- `legacy` — force the existing legacy path syntax;
1316+
- `jsonpath` — force JSONPath syntax.
13171317
If omitted, the scriptlet detects JSONPath automatically for clearly JSONPath-shaped expressions.
13181318

13191319
> Note please that you can use wildcard `*` for chain property name,
@@ -1430,15 +1430,15 @@ example.org#%#//scriptlet('json-prune'[, propsToRemove [, obligatoryProps [, sta
14301430
- `propsToRemove` — optional, string of space-separated properties to remove.
14311431
In `jsonpath` mode only single JSONPath prune expression is supported.
14321432
- `obligatoryProps` — optional, string of space-separated properties
1433-
which must be all present for the pruning to occur
1433+
which must be all present for the pruning to occur.
14341434
In `jsonpath` mode this argument is ignored. Express such preconditions
14351435
directly in `propsToRemove` with leading JSONPath guards and filters.
14361436
- `stack` — optional, string or regular expression that must match the current function call stack trace;
1437-
if regular expression is invalid it will be skipped
1437+
if regular expression is invalid it will be skipped.
14381438
- `mode` — optional, syntax mode selector.
14391439
Supported values:
1440-
- `legacy` — force the existing legacy path syntax
1441-
- `jsonpath` — force JSONPath syntax
1440+
- `legacy` — force the existing legacy path syntax;
1441+
- `jsonpath` — force JSONPath syntax.
14421442
If omitted, the scriptlet detects JSONPath automatically only for clearly JSONPath-shaped expressions,
14431443
otherwise it falls back to legacy syntax.
14441444

@@ -2428,7 +2428,7 @@ https://github.com/gorhill/uBlock/wiki/Resources-Library#no-fetch-ifjs-
24282428
### Syntax
24292429

24302430
```text
2431-
example.org#%#//scriptlet('prevent-fetch'[, propsToMatch[, responseBody[, responseType]]])
2431+
example.org#%#//scriptlet('prevent-fetch'[, propsToMatch[, responseBody[, responseConfig]]])
24322432
```
24332433

24342434
- `propsToMatch` — optional, string of space-separated properties to match; possible props:
@@ -2448,11 +2448,20 @@ example.org#%#//scriptlet('prevent-fetch'[, propsToMatch[, responseBody[, respon
24482448
- colon-separated pair `name:value` string value to customize `responseBody` where
24492449
- `name` — only `length` supported for now
24502450
- `value` — range on numbers, for example `100-300`, limited to 500000 characters
2451-
- `responseType` — optional, string for defining response type,
2452-
original response type is used if not specified. Possible values:
2453-
- `basic`
2454-
- `cors`
2455-
- `opaque`
2451+
- `responseConfig` — optional, string for defining response properties.
2452+
Original response values are used if not specified. Possible values:
2453+
- response type shorthand (for backwards compatibility):
2454+
- `basic`
2455+
- `cors`
2456+
- `error`
2457+
- `opaque`
2458+
- `opaqueredirect`
2459+
- JSON object string with quoted keys and any combination of these properties:
2460+
- `ok` — boolean
2461+
- `redirected` — boolean
2462+
- `status` — non-negative integer from range `0..599`
2463+
- `statusText` — one of `""`, `"OK"`, `"Continue"`, `"Not Found"`
2464+
- `type` — one of the supported response type values above
24562465

24572466
> Usage with no arguments will log fetch calls to browser console;
24582467
> it may be useful for debugging but it is not allowed for prod versions of filter lists.
@@ -2513,6 +2522,16 @@ example.org#%#//scriptlet('prevent-fetch'[, propsToMatch[, responseBody[, respon
25132522
example.org#%#//scriptlet('prevent-fetch', '*', '', 'opaque')
25142523
```
25152524
2525+
1. Prevent all fetch calls and specify response properties
2526+
2527+
```adblock
2528+
! Set multiple response properties at once
2529+
example.org#%#//scriptlet('prevent-fetch', '*', '', '{"status": 404, "statusText": "Not Found", "ok": false}')
2530+
2531+
! Set response type together with other values
2532+
example.org#%#//scriptlet('prevent-fetch', '*', '', '{"type": "opaqueredirect", "redirected": true}')
2533+
```
2534+
25162535
[Scriptlet source](../src/scriptlets/prevent-fetch.js)
25172536
25182537
* * *
@@ -2796,10 +2815,13 @@ example.org#%#//scriptlet('prevent-setInterval'[, matchCallback[, matchDelay]])
27962815
If starts with `!`, scriptlet will not match the stringified callback but all other will be defused.
27972816
If do not start with `!`, the stringified callback will be matched.
27982817
If not set, prevents all `setInterval` calls due to specified `matchDelay`.
2799-
- `matchDelay` — optional, must be an integer.
2818+
- `matchDelay` — optional, must be an integer or a delay range.
28002819
If starts with `!`, scriptlet will not match the delay but all other will be defused.
28012820
If do not start with `!`, the delay passed to the `setInterval` call will be matched.
28022821
Decimal delay values will be rounded down, e.g `10.95` will be matched by `matchDelay` with value `10`.
2822+
Delay ranges are supported in the format `min-max` (matches if `min <= delay <= max`),
2823+
`min-` (matches if `delay >= min`), or `-max` (matches if `delay <= max`).
2824+
Negative delay values behave the same as `0`, so use `-0` to match them.
28032825

28042826
> If `prevent-setInterval` log looks like `setInterval(undefined, 1000)`,
28052827
> it means that no callback was passed to setInterval() and that's not scriptlet issue
@@ -2901,6 +2923,54 @@ example.org#%#//scriptlet('prevent-setInterval'[, matchCallback[, matchDelay]])
29012923
}, 300 + Math.random());
29022924
```
29032925
2926+
1. Prevents `setInterval` calls if the delay is in the `20-50` range
2927+
2928+
```adblock
2929+
example.org#%#//scriptlet('prevent-setInterval', '', '20-50')
2930+
```
2931+
2932+
For instance, only the second of the following calls will be prevented:
2933+
2934+
```javascript
2935+
setInterval(function () {
2936+
window.test = "10 -- executed";
2937+
}, 10);
2938+
setInterval(function () {
2939+
window.test = "30 -- prevented";
2940+
}, 30);
2941+
```
2942+
2943+
1. Prevents `setInterval` calls if the delay is at least `30`
2944+
2945+
```adblock
2946+
example.org#%#//scriptlet('prevent-setInterval', '', '30-')
2947+
```
2948+
2949+
For instance, only the second of the following calls will be prevented:
2950+
2951+
```javascript
2952+
setInterval(function () {
2953+
window.test = "10 -- executed";
2954+
}, 10);
2955+
setInterval(function () {
2956+
window.test = "60 -- prevented";
2957+
}, 60);
2958+
```
2959+
2960+
1. Prevents `setInterval` calls if the delay is negative
2961+
2962+
```adblock
2963+
example.org#%#//scriptlet('prevent-setInterval', '', '-0')
2964+
```
2965+
2966+
For instance, the following call will be prevented:
2967+
2968+
```javascript
2969+
setInterval(function () {
2970+
window.test = "negative -- prevented";
2971+
}, -10);
2972+
```
2973+
29042974
[Scriptlet source](../src/scriptlets/prevent-setInterval.js)
29052975
29062976
* * *
@@ -2932,10 +3002,13 @@ example.org#%#//scriptlet('prevent-setTimeout'[, matchCallback[, matchDelay]])
29323002
If starts with `!`, scriptlet will not match the stringified callback but all other will be defused.
29333003
If do not start with `!`, the stringified callback will be matched.
29343004
If not set, prevents all `setTimeout` calls due to specified `matchDelay`.
2935-
- `matchDelay` — optional, must be an integer.
3005+
- `matchDelay` — optional, must be an integer or a delay range.
29363006
If starts with `!`, scriptlet will not match the delay but all other will be defused.
29373007
If do not start with `!`, the delay passed to the `setTimeout` call will be matched.
29383008
Decimal delay values will be rounded down, e.g `10.95` will be matched by `matchDelay` with value `10`.
3009+
Delay ranges are supported in the format `min-max` (matches if `min <= delay <= max`),
3010+
`min-` (matches if `delay >= min`), or `-max` (matches if `delay <= max`).
3011+
Negative delay values behave the same as `0`, so use `-0` to match them.
29393012

29403013
> If `prevent-setTimeout` log looks like `setTimeout(undefined, 1000)`,
29413014
> it means that no callback was passed to setTimeout() and that's not scriptlet issue
@@ -3037,6 +3110,54 @@ example.org#%#//scriptlet('prevent-setTimeout'[, matchCallback[, matchDelay]])
30373110
}, 300 + Math.random());
30383111
```
30393112
3113+
1. Prevents `setTimeout` calls if the delay is in the `20-50` range
3114+
3115+
```adblock
3116+
example.org#%#//scriptlet('prevent-setTimeout', '', '20-50')
3117+
```
3118+
3119+
For instance, only the second of the following calls will be prevented:
3120+
3121+
```javascript
3122+
setTimeout(function () {
3123+
window.test = "10 -- executed";
3124+
}, 10);
3125+
setTimeout(function () {
3126+
window.test = "30 -- prevented";
3127+
}, 30);
3128+
```
3129+
3130+
1. Prevents `setTimeout` calls if the delay is at least `30`
3131+
3132+
```adblock
3133+
example.org#%#//scriptlet('prevent-setTimeout', '', '30-')
3134+
```
3135+
3136+
For instance, only the second of the following calls will be prevented:
3137+
3138+
```javascript
3139+
setTimeout(function () {
3140+
window.test = "10 -- executed";
3141+
}, 10);
3142+
setTimeout(function () {
3143+
window.test = "60 -- prevented";
3144+
}, 60);
3145+
```
3146+
3147+
1. Prevents `setTimeout` calls if the delay is negative
3148+
3149+
```adblock
3150+
example.org#%#//scriptlet('prevent-setTimeout', '', '-0')
3151+
```
3152+
3153+
For instance, the following call will be prevented:
3154+
3155+
```javascript
3156+
setTimeout(function () {
3157+
window.test = "negative -- prevented";
3158+
}, -10);
3159+
```
3160+
30403161
[Scriptlet source](../src/scriptlets/prevent-setTimeout.js)
30413162
30423163
* * *

wiki/about-trusted-scriptlets.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -873,12 +873,12 @@ https://github.com/gorhill/uBlock/commit/1c9da227d7
873873
example.org#%#//scriptlet('trusted-prune-inbound-object', functionName[, propsToRemove [, obligatoryProps [, stack]]])
874874
```
875875

876-
- `functionName` — required, the name of the function to trap, it must have an object as an argument
877-
- `propsToRemove` — optional, string of space-separated properties to remove
876+
- `functionName` — required, the name of the function to trap, it must have an object as an argument.
877+
- `propsToRemove` — optional, string of space-separated properties to remove.
878878
- `obligatoryProps` — optional, string of space-separated properties
879-
which must be all present for the pruning to occur
879+
which must be all present for the pruning to occur.
880880
- `stack` — optional, string or regular expression that must match the current function call stack trace;
881-
if regular expression is invalid it will be skipped
881+
if regular expression is invalid it will be skipped.
882882

883883
> Note please that you can use wildcard `*` for chain property name,
884884
> e.g. `ad.*.src` instead of `ad.0.src ad.1.src ad.2.src`.

0 commit comments

Comments
 (0)