Static filter syntax·续3

removeparam is a modifier option (like csp) in that it does not cause a network request to be blocked but rather becomes modified before being emitted.

removeparam can be assigned a value. This value will determine which exact parameter from a query string will get removed:


*$removeparam=utm_source

The above filter tells uBO to remove the query parameter utm_source when present in a URL.

The value assigned to removeparam can be a literal regular expression, in which case uBO will remove query parameters matching the regular expression:


*$removeparam=/^utm_/

The above filter will remove all query parameters whose name starts with utm_, regardless of their value. When using a literal regular expression, it gets tested against each query parameter name-value pair assembled into a single string as name=value.

If no values are assigned, all query parameters on a given site will be removed:


||example.org^$removeparam

Poorly crafted removeparam filters can have harmful effects on performance. Experienced filter authors need to understand how to create optimal filters.

Cosmetically added params cannot be removed via removeparam (see related comment: 760#issuecomment-724703650 and invalid issues: #1704, #1767, #1951, #2498)

See also: Filter Performance


replace

<sup>Framework compatibility: Firefox MV2-only</sup>

New in 1.53.1b3.

Can only be used in a trusted-source origin.

See <https://adguard.com/kb/general/ad-filtering/create-own-filters/#replace-modifier>

[Documentation to be completed]


uritransform

Candidate for deprecation, avoid usage. To be further discussed.

Can only be used in a trusted-source origin.

Transform the path/query/hash portion of a URL.

See <https://adguard.com/kb/general/ad-filtering/create-own-filters/#urltransform-modifier>

[Documentation to be completed]

<details><summary>Technical notes</summary>

New in 1.52.3b12 as urltransform.

Renamed in 1.54.1b8 to uritransform.

</details>


urlskip

<sup>Framework compatibility: MV2: full support; MV3: partial support</sup>

New in 1.60.0.

Can only be used in a trusted-source origin.

Extracts a URL from another URL according to one or more transformation steps, thereby skipping over intermediate network request(s) to remote servers. The main purpose is to bypass URLs designed to track whether a user visited a specific URL, typically used in click-tracking links.

The urlskip= option ...

  • ... is valid only when used in a trusted filter list

  • ... is a modifier, i.e. it cannot be used along with other

modifier options in a single filter

  • ... is enforced only on network requests which are not blocked by other filter <sup>(New in dev build 1.60.1rc0+)</sup>.

  • ... if a strict-blocked page matches a urlskip= filter, the page will show the user the destination URL as a result of applying the urlskip filter should they choose to proceed with the navigation <sup>(New in dev build 1.60.1rc1+)</sup>.

The syntax is urlskip=[steps], where steps is a serie of space-separated directives representing the transformation steps to perform to extract the final URL to which a network request should be redirected.

Valid directives:

  • ?name: extracts the value of parameter name

  • &i: extracts the name of the parameter at position i (1-based) <sup>(New in dev build 1.60.1b6+)</sup>

  • #: extracts the hash part as the current string

  • /.../: extracts the first capture group of a regex <sup>(New in dev build 1.60.1b11+)</sup>

  • +https:

  • prepends the current string with https:// protocol in case it lacks a leading protocol

  • or replaces already existing leading http:// protocol with https://

  • -base64: performs base64-decoding on the current string <sup>(New in dev build 1.60.1b1+)</sup>

  • -safebase64: performs safe base64-decoding on the current string <sup>(New in dev build 1.61.3b0+)</sup>

  • -uricomponent: performs URI component-decoding on the current string <sup>(New in dev build 1.60.1b12+)</sup>

  • -blocked: can be used to explicitly allow a urlskip= filter to also apply to blocked network requests <sup>(New in dev build 1.60.1rc0)</sup>

At any given step, the currently extracted string may not necessarily be a valid URL, and more transformation steps may be needed to obtain a valid URL once all the steps are applied.

An unsupported step or a failed step will abort the transformation and no redirection will be performed.

The final computed URL must be a valid URL as per URL API, otherwise the filter will be ignored and no redirection will be performed.

Examples:


||example.com/path/to/tracker$urlskip=?url

The above filter will cause navigation to https://example.com/path/to/tracker?url=https://example.org/ to automatically bypass navigation to example.com and navigate directly to https://example.org/.

It is possible to recursively extract URL parameters by using

more than one directive, example:


||example.com/path/to/tracker$urlskip=?url ?to

The above filter will cause navigation to https://example.com/path/to/tracker?url=https%3A%2F%2Fexample.org%2Fpath%2Fto%2Ftracker%3Fto%3Dhttps%253A%252F%252Fgithub.com%252F to automatically bypass navigation to example.com & example.org and navigate directly to https://github.com/.

Note: No skip will occur if not all extraction directives can be fulfilled in a given URL. For example, https://example.com/path/to/tracker?url=https%3A%2F%2Fexample.org%2Fpath%2Fto%2Ftracker won't be skipped by the filter above because the ?to step can't be fulfilled.


||rdr.btrck.com/aff_c?$urlskip=?aff_sub3 +https

The above filter will cause navigation to https://rdr.btrck.com/aff_c?offer_id=17&aff_id=1&source=55754&aff_sub=www.evekonomisi.net&aff_sub2=&aff_sub3=hepsiburada.com/philips-ca6700-10-espresso-makinesi-kirec-temizleme-solusyonu-p-HBCV00002YNJSF (...) to automatically bypass navigation to rdr.btrck.com and navigate directly to https:// + hepsiburada.com/philips-ca6700-10-espresso-makinesi-kirec-temizleme-solusyonu-p-HBCV00002YNJSF (...) (otherwise URL would be discarded due to a lack of a required protocol), the full URL is here:

<details><summary>(full URL spoiler)</summary>

https://rdr.btrck.com/aff_c?offer_id=17&aff_id=1&source=55754&aff_sub=www.evekonomisi.net&aff_sub2=&aff_sub3=hepsiburada.com/philips-ca6700-10-espresso-makinesi-kirec-temizleme-solusyonu-p-HBCV00002YNJSF&aff_sub4=inf-www.evekonomisi.net-7324&aff_sub5=inf&url=https%3a%2f%2f7t4g.adj. st%2fproduct%3fsku%3dHBCV00002YNJSF%26adj_t%3d16v6nskj_16n3rgcj%26publisher_id%3d{transaction_id}%26offer_id%3d{offer_id}%26campaign%3dwinfluenced%26adgroup%3d{aff_sub}{source}%26creative%3d-aff_sub3- %26adj_deep_link%3dhbapp%253a%252f%252fproduct%253fsku%253dHBCV00002YNJSF%2526adj_t%253d16v6nskj_16n3rgcj%2526utm_source%253dwinfluenced%2526utm_medium%253dinfluencer%2526utm_campaign%253dwinfluenced%2526utm_content%253d- aff_sub3-%2526utm_term%253dinfluencer%2526wt_inf%253d{source}%26adj_install_callback%3dhttps%253a%252f%252fwinfluenced-pixel-bs56cx2ajq-ey. a.run.app%252fapi%252fpixel%252fcallback%252finstall%253fevent_type%253dInstall%2526linkid%253d95O2L4G8A2%2526ltoken%253d16v6nskj_16n3rgcj%2526app_id%253d%7Bapp_id%7D%2526offer_id%253d17%2526advertiser_id%253d{advertiser_id}%2526click_id%253d{transaction_id}%2526app_name%253d%7Bapp_name%7D%2526app_version%253d%7Bapp_version%7D%2526store%253d%7Bstore%7D%2526installed_at%253d%7Binstalled_at%7D%2526ip_address%253d%7Bip_address%7D%2526country%253d%7Bcountry%7D%2526device_name%253d%7Bdevice_name%7Dc%2526device_type%253d%7Bdevice_type%7D%2526os_name%253d%7Bos_name%7D%2526partner_parameters%253d%7Bpartner_parameters%7D%2526debug%253dtrue%26adj_event_callback_m2ril4_wapyen%3dhttps%253a%252f%252fwinfluenced- pixel-bs56cx2ajq-ey. a.run. app%252fapi%252fpixel%252fcallback%252fconversion%253fevent_type%253dConversion%2526linkid%253d95O2L4G8A2%2526ltoken%253d16v6nskj_16n3rgcj%2526etoken%253dm2ril4_wapyen%2526offer_id%253d%257bofferId%257d%2526advertiser_id%253d{advertiser_id}%2526app_id%253d%7Bapp_id%7D%2526click_id%253d{transaction_id}%2526ip_address%253d%7Bip_address%7D%2526country%253d%7Bcountry%7D%2526partner_parameters%253d%7Bpartner_parameters%7D%2526revenue_float%253d%7Brevenue_float%7D%2526currency%253d%7Bcurrency%7D%2526reporting_revenue%253d%7Breporting_revenue%7D%2526reporting_currency%253d%7Breporting_currency%7D%2526os_name%253d%7Bos_name%7D%2526debug%253dtrue

</details>

<br>


||shrinkearn.com/full?$urlskip=?url -base64

The above filter will cause navigation to https://shrinkearn.com/full?api=3dd1f43f5fded450a0e4691e503bf19b31f35f44&url=aHR0cHM6Ly9rcmFrZW5maWxlcy5jb20vdmlldy9zamJ1RmpQVTF2L2ZpbGUuaHRtbA==&type=2 to automatically bypass navigation to shrinkearn.com and navigate directly to https://krakenfiles.com/view/sjbuFjPU1v/file.html (which was base64 decoded from: aHR0cHM6Ly9rcmFrZW5maWxlcy5jb20vdmlldy9zamJ1RmpQVTF2L2ZpbGUuaHRtbA==).


||pixiv.net/jump.php?$urlskip=&1

The above filter will cause navigation to: https://www.pixiv.net/jump.php?https%3A%2F%2Fx.com%2FExample_Username to automatically bypass navigation to pixiv.net and navigate directly to https://x.com/Example_Username (which was % decoded from https%3A%2F%2Fx.com%2FExample_Username).


||click.redditmail.com/CL0/$urlskip=/CL0\/.*?(www\.reddit\.com.+?)(?:\?|%3F)/ -uricomponent +https

The above filter will cause navigation to:

https://click.redditmail.com/CL0/https://www.reddit.com/r/natureisfuckinglit/comments/1f7l41z/orca_pod_saying_hi_to_paddle_boarder/?%24deep_link=true&correlation_id=21bc5fa3-f0f4-43b5-92e4-6d2deb135b8a&post_fullname=t3_1f7l41z&post_index=2&ref=email_digest&ref_campaign=email_digest&ref_source=email&utm_content=post_author/1/01000191bd393638-90cd632e-f420-45fd-a732-27dc3e441ee2-000000/aBs5XoGsoLNHwf95BGM6JzVs4iNSldLNZ9hOBaWN_HA=369

https://click.redditmail.com/CL0/https:%2F%2Fwww.reddit.com/r/natureisfuckinglit/comments/1f7l41z/orca_pod_saying_hi_to_paddle_boarder/%3F%2524deep_link=true&correlation_id=21bc5fa3-f0f4-43b5-92e4-6d2deb135b8a&post_fullname=t3_1f7l41z&post_index=2&ref=email_digest&ref_campaign=email_digest&ref_source=email&utm_content=post_author/1/01000191bd393638-90cd632e-f420-45fd-a732-27dc3e441ee2-000000/aBs5XoGsoLNHwf95BGM6JzVs4iNSldLNZ9hOBaWN_HA=369%5D

to automatically bypass navigation to click.redditmail.com and navigate directly to https:// + www.reddit.com/r/natureisfuckinglit/comments/1f7l41z/orca_pod_saying_hi_to_paddle_boarder/ (after it previously was URI component decoded).

<br>

Given the filter ||example.com^, the filter:


||example.com/path/to/tracker$urlskip=?url

will not prevent strict-blocking when navigating to:

https://example.com/path/to/tracker?url=https://example.org/

However, the filter:


||example.com/path/to/tracker$urlskip=-blocked ?url

will cause the strict-blocking to be ignored and allow navigation

to proceed to the URL extracted as a result of applying the urlskip=

filter: https://example.org/

Related discussion: https://github.com/uBlockOrigin/uBlock-issues/issues/3206#issuecomment-2439627386

<br>

Related issues:

<br>

<details><summary>Technical notes</summary>

First commit in 1.59.1b22.

Last commit in 1.60.1rc1.

</details>


Static extended filtering

Static extended filters are all of these forms:

[hostname(s)]##[expression]

[hostname(s)]#@#[expression]

The most common static extended filters are cosmetic filters, also known as "element hiding filters" in ABP and "cosmetic rules" in AG.


Entity

All static extended filters can apply to a specific entity. For example:


google.*###tads.c

An entity is defined as follows: a formal domain name with the Public Suffix part replaced by a wildcard.

Examples: google.* will apply to all similar Google domain names: google.com, google.com.br, google.ca, google.co.uk, etc. Another example: facebook.* will apply to all similar Facebook domain names: facebook.com, facebook.net.

Since the base domain name gets used to derive the name of the "entity", google.evil.biz would not match google.*.


Hostname regex

Starting with 1.46.1b15, you can use regex-based values as target domain (hostname) for static extended filters, works in base hostname, and also in filter options like: domain=, to= and from=. Examples of usage:

Solves: regex-fied domain:

  • /img[a-z]{3,5}\.buzz/##+js(nowoif) - matches (example): imgabcd.buzz