Page 1 of 1
Blocking by second level domain
Posted: Wed Aug 31, 2016 2:18 pm
by 753543453543
How to block all domains with, for example, "google" as their second level domain.
For instance:
- block:
- google.com, google.net, google.org ...
-
www.google.com, stats.
www.google.com,
www.google.net ...
- not to block:
-
www.google.com.example.com
Re: Blocking by second level domain
Posted: Wed Aug 31, 2016 2:42 pm
by mapx
try
||google.*^
Re: Blocking by second level domain
Posted: Wed Aug 31, 2016 4:05 pm
by 753543453543
Yes, that rule blocks all it needs to block, but also blocks things I do not want it to block.
It block this example address:
www.google.a.a.a.a.a.example.com .
I would like to block all domains with same second-level domain name but not top-level domain.
Re: Blocking by second level domain
Posted: Wed Aug 31, 2016 6:25 pm
by lewisje
To answer your literal question, you need a regex filter (replace
example with your second-level domain):
Code: Select all
/^(http|ws)s?\:\/\/([-\w]*\.)*example\.\w{2,}(\:|\/)/
Below is a more
complicated and
optimized filter that covers even the
authentication section of a URI and non-standard ports, and also covers
Punycode representations of IDNs:
Code: Select all
/^(?:http|ws)s?\:\/\/(?:[-\w%\!\$&'()*+,;=^\\|><"][-\w%\!\$&'()*+,;=^\\|><"]*(?:\:[-\w%\!\$&'()*+,;=^\\|><"][-\w%\!\$&'()*+,;=^\\|><"]*)?@)?(?:[-a-z\d_][-a-z\d_]*\.)*example\.[-a-z\d]{2}[-a-z\d]*\.?(?:\:\d\d{0,4})?\//
A better idea might be to support a new wildcard for matching public suffixes (for example, what about google.
co.uk?):
https://en.wikipedia.org/wiki/Public_Suffix_List
uBlock Origin does this for hiding rules (called "entity-based cosmetic filters") re-using the common * wildcard, and I believe AdBlock for Chrome and Safari once did this (for hiding rules) with the pseudo-TLD
tld:
https://github.com/gorhill/uBlock/wiki/ ... ic-filters
I also thought one of the two allowed a similar wildcard in the $domain= option for blocking rules.
Re: Blocking by second level domain
Posted: Wed Aug 31, 2016 9:49 pm
by 753543453543
Thank you very much.
It works perfectly.
I agree filters should be more controllable, and a public suffix wildcard would be extremely useful.