Block element that precedes a particular element

Posting here is no longer possible, please use the forum of a filter list project, such as EasyList
Locked
Roninnin
Posts: 98
Joined: Thu Apr 09, 2015 11:14 am

Block element that precedes a particular element

Post by Roninnin »

Hello

I've encountered a site that uses obfuscation to disguise its image ads (namely "spiegel.de"). Here's an example of the code they're using:

Code: Select all

<div class="SaLAcBz"><abc class="eWuEFMAEsG"><a href="smz8"><img src="http://cdn2.spiegel.de/images/image-261714-hppano-r1t4-745378.jpg"></a></abc></div><div class="adition" id="content_ad_1" data-position="content_ad_1">
	<script type="text/javascript">
		if (typeof ADI != 'undefined') ADI.ad('content_ad_1');
	</script>
</div>
The image http://cdn2.spiegel.de/images/image-261 ... 745378.jpg is an ad and is indistinguishable from the other regular images that need to remain visible (same domain, subdomains, similar file names etc.). As you can see too, the div attributes are just sequences of seemingly random characters, so there's no way to use a pattern-based filter to hide them.

However, it seems that the following element is almost always a script-based ad, which is detectable thanks to its class attribute "adition". So I was wondering if it's possible to create a filter that can remove an element that precedes an identifiable element. In the above case, the div preceding the div with class attribute "adition". In jQuery there's the prev() function of course, but I don't know what's available in Adblock to do something like that.

If you have any other suggestions as to how I could remove those pesky obfuscated ads...

Thanks in advance for your help.
User avatar
mapx
Posts: 21940
Joined: Thu Jan 06, 2011 2:01 pm

Re: Block element that precedes a particular element

Post by mapx »

try

Code: Select all

spiegel.de##ABC > A:first-child
or

Code: Select all

@@||spiegel.de^$elemhide
@@||spiegel.de^$xmlhttprequest
@@/ad$image,domain=spiegel.de
Roninnin
Posts: 98
Joined: Thu Apr 09, 2015 11:14 am

Re: Block element that precedes a particular element

Post by Roninnin »

Nice try but the "abc" element isn't always present. Here's an example from another page on that site:

Code: Select all

<div id="HRNSJsOn"><img src="http://cdn2.spiegel.de/images/image-052285-thumb-9c8u-769144.jpg"></div><div class="adition" id="billboard_1" data-position="billboard_1">
	<script type="text/javascript">
		if (typeof ADI != 'undefined') ADI.ad('billboard_1');
	</script>
User avatar
mapx
Posts: 21940
Joined: Thu Jan 06, 2011 2:01 pm

Re: Block element that precedes a particular element

Post by mapx »

try all the filters I posted above and provide the specific page link.
Locked