Skip to content

Commit d723d35

Browse files
author
Atlassian Bamboo
committed
deploy: update docs for v2.2.14
1 parent 2670ee4 commit d723d35

3 files changed

Lines changed: 91 additions & 5 deletions

File tree

wiki/about-scriptlets.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
- [prevent-eval-if](#prevent-eval-if)
5454
- [prevent-fab-3.2.0](#prevent-fab-3.2.0)
5555
- [prevent-fetch](#prevent-fetch)
56+
- [prevent-innerHTML](#prevent-innerhtml)
5657
- [prevent-popads-net](#prevent-popads-net)
5758
- [prevent-refresh](#prevent-refresh)
5859
- [prevent-requestAnimationFrame](#prevent-requestanimationframe)
@@ -2255,6 +2256,79 @@ example.org#%#//scriptlet('prevent-fetch'[, propsToMatch[, responseBody[, respon
22552256
22562257
* * *
22572258
2259+
## <a id="prevent-innerhtml"></a> ⚡️ prevent-innerHTML
2260+
2261+
> Added in v2.2.14.
2262+
2263+
Conditionally prevents assignment to `innerHTML` property
2264+
and can replace the value returned by the getter.
2265+
2266+
Related UBO scriptlet:
2267+
https://github.com/gorhill/uBlock/wiki/Resources-Library#prevent-innerhtmljs-
2268+
2269+
### Syntax
2270+
2271+
```text
2272+
example.org#%#//scriptlet('prevent-innerHTML'[, selector[, pattern[, replacement]]])
2273+
```
2274+
2275+
- `selector` — optional, CSS selector to match element. If not specified, matches all elements.
2276+
- `pattern` — optional, string or regular expression to match against the assigned/returned value.
2277+
Prepend with `!` to invert the match. If not specified, matches all values.
2278+
- `replacement` — optional, replacement value to return from getter when pattern matches.
2279+
If not specified, the getter returns the original value unchanged (setter-only mode).
2280+
If specified, enables getter manipulation mode. Possible values:
2281+
- empty string — `''`,
2282+
- custom text.
2283+
2284+
### Examples
2285+
2286+
1. Prevent any `innerHTML` assignment
2287+
2288+
```adblock
2289+
example.org#%#//scriptlet('prevent-innerHTML')
2290+
```
2291+
2292+
1. Prevent `innerHTML` assignment on elements matching selector
2293+
2294+
```adblock
2295+
example.org#%#//scriptlet('prevent-innerHTML', '#ads')
2296+
```
2297+
2298+
1. Prevent `innerHTML` assignment when the value contains "ad"
2299+
2300+
```adblock
2301+
example.org#%#//scriptlet('prevent-innerHTML', '', 'ad')
2302+
```
2303+
2304+
1. Prevent `innerHTML` assignment on specific element when value matches regex
2305+
2306+
```adblock
2307+
example.org#%#//scriptlet('prevent-innerHTML', 'div.ads', '/banner|sponsor/')
2308+
```
2309+
2310+
1. Prevent `innerHTML` assignment when value does NOT match pattern (inverted match)
2311+
2312+
```adblock
2313+
example.org#%#//scriptlet('prevent-innerHTML', '', '!allowed-content')
2314+
```
2315+
2316+
1. Replace innerHTML getter value with empty string when it contains "delete window"
2317+
2318+
```adblock
2319+
example.org#%#//scriptlet('prevent-innerHTML', '', 'delete window', '')
2320+
```
2321+
2322+
1. Replace innerHTML getter value with custom text when pattern matches
2323+
2324+
```adblock
2325+
example.org#%#//scriptlet('prevent-innerHTML', 'div.code', '/evil-script/', 'safe-replacement')
2326+
```
2327+
2328+
[Scriptlet source](../src/scriptlets/prevent-innerHTML.ts)
2329+
2330+
* * *
2331+
22582332
## <a id="prevent-popads-net"></a> ⚡️ prevent-popads-net
22592333
22602334
> Added in v1.0.4.

wiki/about-trusted-scriptlets.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ and waiting for them to render in the DOM first.
2828
First matched element is clicked unless `containsText` is specified.
2929
If `containsText` is specified, then it searches for all given selectors and clicks
3030
the first element containing the specified text.
31-
Deactivates after all elements have been clicked or by 10s timeout.
31+
Deactivates after all elements have been clicked or by timeout (configurable).
3232

3333
### Syntax
3434

3535
```text
36-
example.com#%#//scriptlet('trusted-click-element', selectors[, extraMatch[, delay[, reload]]])
36+
example.com#%#//scriptlet('trusted-click-element', selectors[, extraMatch[, delay[, reload[, observerTimeout]]]])
3737
```
3838
<!-- markdownlint-disable-next-line line-length -->
3939
- `selectors` — required, string with query selectors delimited by comma. The scriptlet supports `>>>` combinator to select elements inside open shadow DOM. For usage, see example below.
@@ -47,14 +47,18 @@ and each of them should match the syntax. Possible `names`:
4747
- `cookie` — test string or regex against cookies on a page
4848
- `localStorage` — check if localStorage item is present
4949
- `containsText` — check if clicked element contains specified text
50-
- `delay` — optional, time in ms to delay scriptlet execution, defaults to instant execution.
51-
Must be a number less than 10000 ms (10s)
50+
- `delay` — optional, time in **ms** to delay scriptlet execution, defaults to instant execution.
51+
Must be a number less than `observerTimeout` (default 10 _seconds_)
52+
which can be configured.
5253
- `reload` — optional, string with reloadAfterClick marker and optional value. Possible values:
5354
- `reloadAfterClick` - reloads the page after all elements have been clicked,
5455
with default delay — 500ms
5556
- colon-separated pair `reloadAfterClick:value` where
5657
- `value` — time delay in milliseconds before reloading the page, after all elements
57-
have been clicked. Must be a number less than 10000 ms (10s)
58+
have been clicked. Must be a number less than `observerTimeout`.
59+
- `observerTimeout` — optional, time in **seconds** to use
60+
instead default 10 seconds observer timeout.
61+
Must be an integer number and more than 0.
5862

5963
<!-- markdownlint-disable line-length -->
6064

@@ -134,6 +138,12 @@ and each of them should match the syntax. Possible `names`:
134138
example.com#%#//scriptlet('trusted-click-element', 'button[name="agree"], button[name="check"], input[type="submit"][value="akkoord"]', '', '1000', 'reloadAfterClick:200')
135139
```
136140

141+
1. Extend observer timeout to 40 seconds to allow clicking elements that appear after user interaction
142+
143+
```adblock
144+
example.com#%#//scriptlet('trusted-click-element', 'button[name="agree"]', '', '', '', '40')
145+
```
146+
137147
<!-- markdownlint-enable line-length -->
138148

139149
[Scriptlet source](../src/scriptlets/trusted-click-element.ts)

wiki/compatibility-table.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
| [prevent-eval-if](../wiki/about-scriptlets.md#prevent-eval-if) | noeval-if.js (prevent-eval-if.js) | |
5757
| [prevent-fab-3.2.0](../wiki/about-scriptlets.md#prevent-fab-3.2.0) | | |
5858
| [prevent-fetch](../wiki/about-scriptlets.md#prevent-fetch) | prevent-fetch.js (no-fetch-if.js) | |
59+
| [prevent-innerHTML](../wiki/about-scriptlets.md#prevent-innerHTML) | prevent-innerHTML | |
5960
| [prevent-xhr](../wiki/about-scriptlets.md#prevent-xhr) | prevent-xhr.js (no-xhr-if.js) | |
6061
| [prevent-popads-net](../wiki/about-scriptlets.md#prevent-popads-net) | | |
6162
| [prevent-refresh](../wiki/about-scriptlets.md#prevent-refresh) | prevent-refresh.js (refresh-defuser.js) | |
@@ -183,3 +184,4 @@
183184
| | noeval.js | |
184185
| | noop-0.5s.mp3 | |
185186
| | sensors-analytics.js | |
187+
| | nitropay_ads.js | |

0 commit comments

Comments
 (0)