Skip to content

Loading…

Blocking parent element #1458

Open
hanxue opened this Issue · 4 comments

4 participants

@hanxue

Is there a way to block a parent element? For example on http://www.videostream.biz , the overlay is in this format:

<div id="nlPXr7spfcrL" class="ZtTQnXASrAfB" style="background: rgb(221, 221, 221) none repeat scroll 0% 0%; top: 100px; opacity: 1; visibility: visible;"><h1>Adblocker detected! Please consider reading this notice.</h1><p>We've detected that you are using AdBlock Plus ore some other adblocking software which is preventing the page from fully loading.</p>
<p>We need money to operate the site, and almost all of it comes from our online advertising.</p>
<p><strong>Please add <a title="Video Streaming" href="http://www.videostream.biz" target="_blank">www.videostream.biz</a> to your ad blocking whitelist or disable your adblocking software.</strong></p>
<p><!--JuicyAds v2.0--><br>
<iframe src="http://adserver.juicyads.com/adshow.php?adzone=384764" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" height="258" width="308"></iframe><br>
<!--JuicyAds END--></p>
<a class="close-ZtTQnXASrAfB">×</a></div>

The <div> id as well as class are dynamically generated, statically blocking is not a solution. How can I write a selector for <h1>Adblocker detected! and selecting the parent <div>?

Even something like videostream.biz##h1 < div will be sufficient.

@Betsy25

I'm not a pro, but perhaps adding :

www.videostream.biz/wp-content/uploads/an-temp/*$script

... to "My Filters" might get the job done.

See if that doesn't break other expected functionality.

@lewisje

Once your browser supports the :has() relational pseudo-selector in CSS Selectors Level 4, currently in draft form, you can write a hiding rule like videostream.biz##div:has(> h1) (similar to jQuery's implementation of this selector); at the moment, however, there is no way in CSS to select an element based on its descendant elements, and even in Selectors Level 4, there is no way to select an element by its text content.

Maybe uBlock could enhance its hiding-selector syntax by developing a custom selector engine (possibly translating any rule with :has() in it into an XPath selector), but it would then need to have a hiding strategy other than just injecting a bunch of style rules.

@Gitoffthelawn

Wow. That's great news that several new relational pseudo classes are still slated for CSS4. Do you know when the draft is supposed to be finalized, or if any browsers will implement them before the draft is finalized?

You also mentioned XPath selectors... does uBlock (or ABE/ABP for that matter) support XPath selectors in any way?

@lewisje

What I was talking about was possibly translating certain rules from future specifications into XPath, not supporting XPath itself in hiding rules, but the performance issues would likely be similar to supporting XPath directly in rules, which an ABP developer cited for why ABP doesn't support them: https://adblockplus.org/forum/viewtopic.php?t=21209

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.