1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-16 15:33:38 +01:00

Updated "regex-based..." (better formatting + typo fixed + more examples)

garry-ut99 2024-07-07 07:16:17 +00:00
parent a7a5a0f262
commit 519babf43d

@ -956,16 +956,20 @@ Since the base domain name gets used to derive the name of the "entity", `google
#### Hostname regex #### Hostname regex
Starting with [1.46.1b15](https://github.com/gorhill/uBlock/commit/81498474d6d440b032681aa9952d593749b39efb), you can use regex-based values as target domain (hostname) for static extended filters. Examples of usage: Starting with [1.46.1b15](https://github.com/gorhill/uBlock/commit/81498474d6d440b032681aa9952d593749b39efb), you can use regex-based values as target domain (hostname) for static extended filters. Examples of usage:
- solves: [regex-fied domain](https://github.com/uBlockOrigin/uBlock-issues/discussions/2234):
Solves: [regex-fied domain](https://github.com/uBlockOrigin/uBlock-issues/discussions/2234):
- `/img[a-z]{3,5}\.buzz/##+js(nowoif)` - matches (example): `imgabcd.buzz` - `/img[a-z]{3,5}\.buzz/##+js(nowoif)` - matches (example): `imgabcd.buzz`
- solves : [Add support for domain double wildcarding in hiding rules (Would be a huge gamechanger for Nitter)](https://github.com/uBlockOrigin/uBlock-issues/issues/2905):
Solves: [Add support for domain double wildcarding in hiding rules (Would be a huge gamechanger for Nitter)](https://github.com/uBlockOrigin/uBlock-issues/issues/2905):
- `/^nitter\.[^.]+\.[^.]+$/##.timeline-item:has-text(owned)` - matches (example): `nitter.abc.com`, but not `nitter.com` and not `nitter.abc.xyz.com` - `/^nitter\.[^.]+\.[^.]+$/##.timeline-item:has-text(owned)` - matches (example): `nitter.abc.com`, but not `nitter.com` and not `nitter.abc.xyz.com`
- `/^nitter(?:\.[^.]+){1,2}$/##.timeline-item:has-text(owned)` - matches (example): `nitter.com` + `nitter.abc.com`, but not `nitter.abc.xyz.com` - `/^nitter(?:\.[^.]+){1,2}$/##.timeline-item:has-text(owned)` - matches (example): `nitter.com` + `nitter.abc.com`, but not `nitter.abc.xyz.com`
- solves: [Hiding rules are unable to specify to only block on the core domain and none of the subdomains (e.g. ~*.example.org doesn't work)](https://github.com/uBlockOrigin/uBlock-issues/issues/3291):
Solves: [Hiding rules are unable to specify to only block on the core domain and none of the subdomains (e.g. ~*.example.org doesn't work)](https://github.com/uBlockOrigin/uBlock-issues/issues/3291):
- `/^example\.org$/##h1` - matches only `example.org` without subdomains - `/^example\.org$/##h1` - matches only `example.org` without subdomains
- `/^www\.example\.org$/##h1` - matches only `www.example.org` without subdomains and without `example.org` - `/^www\.example\.org$/##h1` - matches only `www.example.org` without subdomains and without `example.org`
- `/^(?:www\.)?example\.org$/##h1` - matches only `example.org` + `www.example.org` without subdomains - `/^(?:www\.)?example\.org$/##h1` - matches only `example.org` + `www.example.org` without subdomains
- `/^example\.org$/,somesite.org,somesite2.*##h1` - can be combined with normal names and entities - `/^example\.org$/,somesite.org,somesite2.*##h1` - can be combined with normal names and entities
- `org,~/^example\.org$/##h1` - can be excluded (negated): matches `org` with all subdomains, without `example.org`, but still matches subdomains of `example.org` (for example `www.example.org`)
Use sparingly, when no other solution is practical from a maintenance point of view -- keeping in mind that uBO has to iterate through all the regex-based values, unlike plain hostname or entity-based values which are mere lookups. Use sparingly, when no other solution is practical from a maintenance point of view -- keeping in mind that uBO has to iterate through all the regex-based values, unlike plain hostname or entity-based values which are mere lookups.