Filtering parent elements by finding their children.

Everything about using Adblock Plus on Google Chrome
Post Reply
WithMetta
Posts: 1
Joined: Thu May 24, 2012 11:23 pm

Filtering parent elements by finding their children.

Post by WithMetta »

Code: Select all

<div>
   <a href="adspam.com"> <--- What I use to find the ad
   <p>Crap text I don't want to see</p>
</div>
Anyway I could hide the parent div?
User avatar
mapx
Posts: 21940
Joined: Thu Jan 06, 2011 2:01 pm

Re: Filtering parent elements by finding their children.

Post by mapx »

if your site is example.com, try:

example.com##a[href*="adspam.com"]
lewisje
Posts: 2743
Joined: Mon Jun 14, 2010 12:07 pm

Re: Filtering parent elements by finding their children.

Post by lewisje »

^That's not what the OP wanted exactly...

Anyway, you can't do what you're asking about until the following CSS4 feature is implemented: http://www.w3.org/TR/selectors4/#subject
Once it is, you can use something like example.com##$div>a[href*="adspam.com"] where the $ indicates the element to actually apply the CSS to.

In the meantime, you can use mapx's rule along with the following: example.com##a[href*="adspam.com"]+p
This rule hides all p elements adjacent to a elements with href containing "adspam.com"; mapx's rule hides those a elements.
There's a buzzin' in my brain I really can't explain; I think about it before they make me go to bed.
Zlatin Zlatev

Re: Filtering parent elements by finding their children.

Post by Zlatin Zlatev »

If all your other divs on page have class or id, you could filter them out like

Code: Select all

div:not([class]):not([id])
It is not quite you want, but this worked for me in one particular overlay div case
myname
Posts: 1
Joined: Fri Dec 16, 2016 1:53 pm

Re: Filtering parent elements by finding their children.

Post by myname »

how do i block this whole element when there is "PROMO" as marked on the picture
Image
User avatar
mapx
Posts: 21940
Joined: Thu Jan 06, 2011 2:01 pm

Re: Filtering parent elements by finding their children.

Post by mapx »

you cannot do it, work in progress ..
Post Reply