Skip to content

Commit 1258abf

Browse files
author
Atlassian Bamboo
committed
deploy: update docs for v2.2.16
1 parent d8f12eb commit 1258abf

2 files changed

Lines changed: 236 additions & 63 deletions

File tree

wiki/about-scriptlets.md

Lines changed: 169 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,13 @@
4949
- [prevent-adfly](#prevent-adfly)
5050
- [prevent-bab](#prevent-bab)
5151
- [prevent-canvas](#prevent-canvas)
52+
- [prevent-constructor](#prevent-constructor)
5253
- [prevent-element-src-loading](#prevent-element-src-loading)
5354
- [prevent-eval-if](#prevent-eval-if)
5455
- [prevent-fab-3.2.0](#prevent-fab-3.2.0)
5556
- [prevent-fetch](#prevent-fetch)
5657
- [prevent-innerHTML](#prevent-innerhtml)
58+
- [prevent-navigation](#prevent-navigation)
5759
- [prevent-popads-net](#prevent-popads-net)
5860
- [prevent-refresh](#prevent-refresh)
5961
- [prevent-requestAnimationFrame](#prevent-requestanimationframe)
@@ -66,6 +68,7 @@
6668
- [remove-cookie](#remove-cookie)
6769
- [remove-in-shadow-dom](#remove-in-shadow-dom)
6870
- [remove-node-text](#remove-node-text)
71+
- [remove-request-query-parameter](#remove-request-query-parameter)
6972
- [scorecardresearch-beacon](#scorecardresearch-beacon)
7073
- [set-attr](#set-attr)
7174
- [set-constant](#set-constant)
@@ -1923,7 +1926,7 @@ https://gitlab.com/eyeo/snippets/-/blob/main/source/behavioral/prevent-listener.
19231926
<!-- markdownlint-disable line-length -->
19241927

19251928
```text
1926-
example.org#%#//scriptlet('prevent-addEventListener'[, typeSearch[, listenerSearch[, additionalArgName, additionalArgValue]]])
1929+
example.org#%#//scriptlet('prevent-addEventListener'[, typeSearch[, listenerSearch[, additionalArgName, additionalArgValue[, noProtect]]]])
19271930
```
19281931

19291932
<!-- markdownlint-enable line-length -->
@@ -1938,6 +1941,11 @@ example.org#%#//scriptlet('prevent-addEventListener'[, typeSearch[, listenerSear
19381941
for `elements` it can be a CSS selector or one of the following values:
19391942
- `window`
19401943
- `document`
1944+
- `noProtect` — optional, if set to `'true'`, the scriptlet will use simple assignment instead of
1945+
`Object.defineProperty` with a no-op setter. This allows other scriptlets or tools to override
1946+
`addEventListener` later if needed. By default, the scriptlet protects the override from being
1947+
overwritten by website scripts. If compatibility with other scriptlets is needed,
1948+
set this parameter to `'true'`.
19411949

19421950
### Examples
19431951

@@ -1985,6 +1993,12 @@ example.org#%#//scriptlet('prevent-addEventListener'[, typeSearch[, listenerSear
19851993
});
19861994
```
19871995
1996+
1. Prevent 'click' listeners and allow other scriptlets to override `addEventListener`
1997+
1998+
```adblock
1999+
example.org#%#//scriptlet('prevent-addEventListener', 'click', '', '', '', 'true')
2000+
```
2001+
19882002
[Scriptlet source](../src/scriptlets/prevent-addEventListener.js)
19892003
19902004
* * *
@@ -2074,6 +2088,64 @@ example.org#%#//scriptlet('prevent-canvas'[, contextType])
20742088
20752089
* * *
20762090
2091+
## <a id="prevent-constructor"></a> ⚡️ prevent-constructor
2092+
2093+
> Added in v2.2.16.
2094+
2095+
Prevents a constructor call if the constructor name
2096+
and optionally the first argument match the specified criteria.
2097+
This scriptlet is useful for blocking constructors like `Promise` or `MutationObserver`
2098+
that can be used to circumvent existing scriptlets like `prevent-addEventListener`.
2099+
2100+
### Syntax
2101+
2102+
```text
2103+
example.org#%#//scriptlet('prevent-constructor', constructorName[, argumentSearch])
2104+
```
2105+
2106+
- `constructorName` — required, string, the name of the constructor to prevent,
2107+
e.g., "Promise", "MutationObserver".
2108+
Must be a property of the global `window` object.
2109+
- `argumentsMatch` — optional, string or regular expression,
2110+
or JSON array of patterns matching arguments passed to the constructor.
2111+
Defaults to match all constructors if not specified.
2112+
Possible values:
2113+
- string — matches the first argument only;
2114+
- JSON array — matches arguments positionally, should be wrapped in `[]`;
2115+
use `"*"` to skip positions, e.g., if only second argument should be matched.
2116+
Invalid regular expression or JSON will cause exit and rule will not work.
2117+
2118+
### Examples
2119+
2120+
1. Prevent all `MutationObserver` constructor calls
2121+
2122+
```adblock
2123+
example.org#%#//scriptlet('prevent-constructor', 'MutationObserver')
2124+
```
2125+
2126+
1. Prevent `Promise` constructor calls where the first argument contains `adblock`
2127+
2128+
```adblock
2129+
example.org#%#//scriptlet('prevent-constructor', 'Promise', 'adblock')
2130+
```
2131+
2132+
1. Prevent `MutationObserver` calls where the first argument matches a regexp
2133+
2134+
```adblock
2135+
example.org#%#//scriptlet('prevent-constructor', 'MutationObserver', '/detect.*ad/')
2136+
```
2137+
2138+
1. Prevent `MutationObserver` calls where the second argument contains `attributes`,
2139+
and matching of the first argument is skipped
2140+
2141+
```adblock
2142+
example.org#%#//scriptlet('prevent-constructor', 'MutationObserver', '["*", "attributes"]')
2143+
```
2144+
2145+
[Scriptlet source](../src/scriptlets/prevent-constructor.ts)
2146+
2147+
* * *
2148+
20772149
## <a id="prevent-element-src-loading"></a> ⚡️ prevent-element-src-loading
20782150
20792151
> Added in v1.6.2.
@@ -2329,6 +2401,52 @@ example.org#%#//scriptlet('prevent-innerHTML'[, selector[, pattern[, replacement
23292401
23302402
* * *
23312403
2404+
## <a id="prevent-navigation"></a> ⚡️ prevent-navigation
2405+
2406+
> Added in v2.2.16.
2407+
2408+
Prevents navigation to URL matching the specified pattern by intercepting the `navigate` event.
2409+
2410+
### Syntax
2411+
2412+
```text
2413+
example.org#%#//scriptlet('prevent-navigation'[, urlPattern])
2414+
```
2415+
2416+
- `urlPattern` — optional, string, regular expression or `location.href` keyword to match URL.
2417+
2418+
> Usage with no arguments will log navigation attempts to browser console.
2419+
2420+
### Examples
2421+
2422+
1. Prevent navigation to URL containing `ads`:
2423+
2424+
```adblock
2425+
example.org#%#//scriptlet('prevent-navigation', 'ads')
2426+
```
2427+
2428+
1. Prevent navigation to URLs matching regex:
2429+
2430+
```adblock
2431+
example.org#%#//scriptlet('prevent-navigation', '/foo.*bar/')
2432+
```
2433+
2434+
1. Prevent `location.reload`:
2435+
2436+
```adblock
2437+
example.org#%#//scriptlet('prevent-navigation', 'location.href')
2438+
```
2439+
2440+
1. Log all navigation attempts without blocking:
2441+
2442+
```adblock
2443+
example.org#%#//scriptlet('prevent-navigation')
2444+
```
2445+
2446+
[Scriptlet source](../src/scriptlets/prevent-navigation.ts)
2447+
2448+
* * *
2449+
23322450
## <a id="prevent-popads-net"></a> ⚡️ prevent-popads-net
23332451
23342452
> Added in v1.0.4.
@@ -3195,6 +3313,56 @@ If matched, the whole text will be removed. Case sensitive.
31953313
31963314
* * *
31973315
3316+
## <a id="remove-request-query-parameter"></a> ⚡️ remove-request-query-parameter
3317+
3318+
> Added in v2.2.16.
3319+
3320+
Removes a specified query parameter from matched outgoing requests.
3321+
3322+
Related ABP source:
3323+
https://gitlab.com/eyeo/anti-cv/snippets/-/blob/92f9b84bd0d34dbd0e3c1bfe3ff2062863c7714a/source/behavioral/strip-fetch-query-parameter.js
3324+
3325+
### Syntax
3326+
3327+
```text
3328+
example.org#%#//scriptlet('remove-request-query-parameter', parametersToRemove[, urlPattern])
3329+
```
3330+
3331+
- `parametersToRemove` — required, either a single regular expression (starting with `/`)
3332+
or a list of literal query parameter names separated by `,`.
3333+
Mixing regular expressions and literal strings is not allowed.
3334+
- `urlPattern` — optional, a string or regular expression to match request URLs.
3335+
3336+
### Examples
3337+
3338+
1. Remove a specific query parameter from all requests:
3339+
3340+
```adblock
3341+
example.org#%#//scriptlet('remove-request-query-parameter', 'utm_source')
3342+
```
3343+
3344+
1. Remove multiple query parameters from all requests:
3345+
3346+
```adblock
3347+
example.org#%#//scriptlet('remove-request-query-parameter', 'utm_source,utm_medium,utm_campaign')
3348+
```
3349+
3350+
1. Remove a specific query parameter from requests matching a URL pattern:
3351+
3352+
```adblock
3353+
example.org#%#//scriptlet('remove-request-query-parameter', 'ad_config_id', '/playback/')
3354+
```
3355+
3356+
1. Remove query parameters matching a regular expression:
3357+
3358+
```adblock
3359+
example.org#%#//scriptlet('remove-request-query-parameter', '/^utm_/', '/api/')
3360+
```
3361+
3362+
[Scriptlet source](../src/scriptlets/remove-request-query-parameter.ts)
3363+
3364+
* * *
3365+
31983366
## <a id="scorecardresearch-beacon"></a> ⚡️ scorecardresearch-beacon
31993367
32003368
> Added in v1.10.25.

0 commit comments

Comments
 (0)