13

How can I use a wildcard in uBlock Origin? I've tried to figure out how to do it, but I'm a little bit confused. I just want to simplify all of these rules into one rule:

www.dailymail.co.uk###js-article-text > div:nth-of-type(2) > div:nth-of-type(2)
www.dailymail.co.uk###js-article-text > div:nth-of-type(2) > div:nth-of-type(3)
www.dailymail.co.uk###js-article-text > div:nth-of-type(2) > div:nth-of-type(4)
www.dailymail.co.uk###js-article-text > div:nth-of-type(2) > div:nth-of-type(5)
www.dailymail.co.uk###js-article-text > div:nth-of-type(2) > div:nth-of-type(6)
www.dailymail.co.uk###js-article-text > div:nth-of-type(2) > div:nth-of-type(7)
www.dailymail.co.uk###js-article-text > div:nth-of-type(2) > div:nth-of-type(9)
www.dailymail.co.uk###js-article-text > div:nth-of-type(2) > div:nth-of-type(10)

Is it possible to give a range of numbers, or a list of specific numbers, or simply an asterisk? Thanks!

grgoelyk
  • 397
  • 1
  • 3
  • 12

3 Answers3

8

You may be able to express the desired block with an arithmetic formula. For example, to block all elements except the very first one, use nth-of-type(n+2). Apparently, n starts from 0, so the blocking will skip the first element, but block everything afterwards.

I use this to block articles automatically loaded by the god-awful sites, that employ the "endless stream" approach to reader-engagement...

Mikhail T.
  • 3,043
  • 3
  • 29
  • 46
7

You can use 'odd' and 'even' as placeholders:

www.dailymail.co.uk###js-article-text > div:nth-of-type(even) > div:nth-of-type(even)
www.dailymail.co.uk###js-article-text > div:nth-of-type(even) > div:nth-of-type(odd)

See https://www.w3schools.com/cssref/sel_nth-of-type.asp

Sindbad103
  • 86
  • 1
  • That can be simplified to www.dailymail.co.uk###js-article-text > div:nth-of-type(even) > div:nth-of-type(n) – jlo Jul 01 '20 at 15:48
1

This will delete from all sites:

###js-article-text > div:nth-of-type.*

This will delete from only this site

www.dailymail.co.uk###js-article-text > div:nth-of-type

NOTE: in both cases delete the first line starting with !

That line will only do instants, meaning next time you log in it will ignore your rule on any page of that site except that page Deleting line will make rule apply for entire site.

Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
Clint
  • 11
  • 1
  • 1
    Wild card # (this will add depth to webpage) so ## is 1 page in ### is page within a page etc.. so (#js-article-text > div:nth-of-type.*) will do main page – Clint Oct 31 '18 at 01:15