updated no-fetch-if and no-xhr-if documentation

D4niloMR 2024-09-23 15:29:57 -03:00
parent 1f4da2f0a2
commit 9390e02e7b

@ -653,19 +653,31 @@ Parameters:
- optional, space-separated list of conditions which must be ALL fulfilled in order for the defusing to take place:
- string/_regular expression_, prefixed by `!` for negation (new in [1.59.1b13](https://github.com/gorhill/uBlock/commit/e8202af11d)), matching in URL passed to `fetch()` call
- colon-separated `name:value` pairs of [`init` option name](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters) and string/_regular expression_ matching in value of that option passed to `fetch()` call.
- optional, arguments to define the response body, possible values:
- `true` to randomize the response, random 10-character string <sup>[1.51.1b15](https://github.com/gorhill/uBlock/commit/418087d)</sup>
- `emptyObj` to return the response value as empty object <sup>[1.54.1rc2](https://github.com/gorhill/uBlock/commit/e1ae17e)</sup>
- `emptyArr` to return the response value as empty array <sup>[1.54.1rc2](https://github.com/gorhill/uBlock/commit/e1ae17e)</sup>
- `emptyStr` to return the response value as empty string <sup>[1.54.1rc2](https://github.com/gorhill/uBlock/commit/e1ae17e)</sup>
- `length:min[-max]` to fulfill the response with randomized text with length specified, limited to 500000 characters <sup>[1.54.1b1](https://github.com/gorhill/uBlock/commit/6aeab2a)</sup>
- `war:[name of resource]` to fulfill the response with the content of a [web_accessible_resources](https://github.com/gorhill/uBlock/tree/master/src/web_accessible_resources) resource <sup>[1.54.1b1](https://github.com/gorhill/uBlock/commit/6aeab2a)</sup>
- optional, (new in [1.58.1rc4](https://github.com/gorhill/uBlock/commit/e785b99338)), string for defining response type / JSON string with
properties to set on the returned response instance, original response type is used if not specified:
- `ok`, supported values: `false`, `true`
- `type`, supported values: `"basic"`, `"cors"`, `"opaque"`
- `type`, supported values: `"basic"`, `"cors"`, `"default"`, `"error"`, `"opaque"`
- `statusText`, supported values: `""`, `"Not Found"`. defaults
to `"OK"` when not overridden. <sup>[1.58.1rc5](https://github.com/gorhill/uBlock/commit/9ce30563613495f5b609211c017aed580847a9cf)</sup>
When used without parameters, the parameters passed to `no-fetch-if` will be logged to the console, as `uBO: fetch([...list of arguments...])`.
Examples:
- `example.com##+js(no-fetch-if, method:HEAD)`
- `example.com##+js(no-fetch-if, adsbygoogle.js)`
- `example.com##+js(no-fetch-if, !negatedValue)`
- `example.com##+js(no-fetch-if, adsbygoogle.js method:HEAD)`
- `example.com##+js(no-fetch-if, /adsbygoogle.js$/ method:/HEAD|POST/)`
- `example.com##+js(no-fetch-if, !negatedValue)`
- `example.com##+js(no-fetch-if, adsbygoogle.js, length:11000)`
- `example.com##+js(no-fetch-if, adsbygoogle.js, war:googlesyndication_adsbygoogle.js)`
- `example.com##+js(no-fetch-if, doubleclick, , '{"type": "opaque"}')`
See also:
- [AdGuard `prevent-fetch`](https://github.com/AdguardTeam/Scriptlets/blob/master/wiki/about-scriptlets.md#prevent-fetch)
@ -857,8 +869,15 @@ Defuses [XMLHttpRequest](https://developer.mozilla.org/en-US/docs/Web/API/XMLHtt
Parameters:
- optional, space-separated list of conditions which must be ALL fulfilled in order for the defusing to take place:
- string/_regular expression_ matching in URL passed to XMLHttpRequest `open()` call
- string/_regular expression_, prefixed by `!` for negation, matching in URL passed to XMLHttpRequest `open()` call
- colon-separated `name:value` pairs of [XMLHttpRequest method `open()`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/open#parameters) parameter names (only `method` and `url` currently supported) and string/_regular expression_ matching in value of passed argument.
- optional, arguments to define the response body, possible values:
- `true` to randomize the response, random 10-character string <sup>[1.51.1b15](https://github.com/gorhill/uBlock/commit/418087d)</sup>
- `emptyObj` to return the response value as empty object <sup>[1.54.1rc2](https://github.com/gorhill/uBlock/commit/e1ae17e)</sup>
- `emptyArr` to return the response value as empty array <sup>[1.54.1rc2](https://github.com/gorhill/uBlock/commit/e1ae17e)</sup>
- `emptyStr` to return the response value as empty string <sup>[1.54.1rc2](https://github.com/gorhill/uBlock/commit/e1ae17e)</sup>
- `length:min[-max]` to fulfill the response with randomized text with length specified, limited to 500000 characters <sup>[1.54.1b1](https://github.com/gorhill/uBlock/commit/6aeab2a)</sup>
- `war:[name of resource]` to fulfill the response with the content of a [web_accessible_resources](https://github.com/gorhill/uBlock/tree/master/src/web_accessible_resources) resource <sup>[1.51.1b16](https://github.com/gorhill/uBlock/commit/bf591d9)</sup>
When used without parameters, the parameters passed to `no-xhr-if` will be logged to the console, as `uBO: xhr.open(...list of arguments...)`.
@ -867,6 +886,8 @@ Examples:
- `example.com##+js(no-xhr-if, adsbygoogle.js)`
- `example.com##+js(no-xhr-if, adsbygoogle.js method:HEAD)`
- `example.com##+js(no-xhr-if, /adsbygoogle.js$/ method:/HEAD|POST/)`
- `example.com##+js(no-xhr-if, adsbygoogle.js, length:11000)`
- `example.com##+js(no-xhr-if, doubleclick.net/instream/ad_status.js, war:doubleclick_instream_ad_status.js)`
Also see:
- [AdGuard `prevent-xhr`](https://github.com/AdguardTeam/Scriptlets/blob/master/wiki/about-scriptlets.md#prevent-xhr)