Cannot block elements using a class starting with underscore

Everything about using Adblock Plus on Google Chrome
Post Reply
seanb
Posts: 4
Joined: Wed May 25, 2016 2:21 am

Cannot block elements using a class starting with underscore

Post by seanb »

Hello,

I am trying to add a filter for blocking an element starting with underscore, but I can't get it to work. I've tried escaping the character and using the attribute selector, but this isn't working either.
The element only shows up when adblock plus is already enabled since the site replaces the blocked ads with the element I am trying to block.

The specific page is

Code: Select all

http://myanimelist.net/anime/813/Dragon_Ball_Z
and the class is '_unit'.

I've tried the following:
myanimelist.net##div._unit
myanimelist.net##div[class~="_unit"]
myanimelist.net##div.\_unit
myanimelist.net##div.\\_unit
myanimelist.net##div.__unit

The first two actually select the element I want with jQuery. The last three were various failed attempts at escaping the underscore.

I appreciate your help!
User avatar
mapx
Posts: 21940
Joined: Thu Jan 06, 2011 2:01 pm

Re: Cannot block elements using a class starting with underscore

Post by mapx »

add

Code: Select all

@@||myanimelist.net^$generichide
myanimelist.net##DIV[style^="padding: 20px"]
the _unit class can't be directly hidden due to !important stuff

<div class="_unit" style="width:336px; height:280px; display: block !important;">
seanb
Posts: 4
Joined: Wed May 25, 2016 2:21 am

Re: Cannot block elements using a class starting with underscore

Post by seanb »

Thanks! What is the purpose of the first line containing "generichide"? I mostly understand what the docs said about this, but I'm not sure what the impact would be for my use case.

Thanks again.

EDIT: Can you think of a way to still use the "_unit" class by capturing all elements inside of that element? Would doing this get around the "!important" issue?
User avatar
mapx
Posts: 21940
Joined: Thu Jan 06, 2011 2:01 pm

Re: Cannot block elements using a class starting with underscore

Post by mapx »

"they" are testing if some elements are on page (exactly some css elements whitelisted by generichide keyword). So, they'll think there is no adblock there and they wont push on page those annoying _unit classes.
seanb
Posts: 4
Joined: Wed May 25, 2016 2:21 am

Re: Cannot block elements using a class starting with underscore

Post by seanb »

Okay, thanks a lot!
LordZounds
Posts: 3
Joined: Sat May 28, 2016 5:36 pm

Re: Cannot block elements using a class starting with underscore

Post by LordZounds »

Hi,

I haven't done much with filters before, so I'm not entirely sure what I'm doing.

It seems the solution mapx post mostly works, but it doesn't always remove the spacing for the ads. It seems to only remove the spacing for the two ads in the middle of anime pages, but not for example the one at the bottom. For a more clear example, it does not remove the one in the top-right on this page:

http://myanimelist.net/search/all?q=test

Is there a way to modify that second line for different pages?
User avatar
mapx
Posts: 21940
Joined: Thu Jan 06, 2011 2:01 pm

Re: Cannot block elements using a class starting with underscore

Post by mapx »

in this specific case it's not possible due to !important keyword used by the site.

However, you could use (install it) tampermonkey extension, then go to
https://greasyfork.org/en/scripts/14720 ... -important

and install that userscript (just click "install this script") in tampermonkey

add then this filter

Code: Select all

myanimelist.net##._unit
The userscript above can help in many other cases (it helps disabling that !important stuff)
LordZounds
Posts: 3
Joined: Sat May 28, 2016 5:36 pm

Re: Cannot block elements using a class starting with underscore

Post by LordZounds »

mapx, that worked perfectly, thanks a lot!

Can using that script and ignoring the !important keyword cause any problems on other sites?
User avatar
mapx
Posts: 21940
Joined: Thu Jan 06, 2011 2:01 pm

Re: Cannot block elements using a class starting with underscore

Post by mapx »

Not as far as I know, they are only enforcing those elements using !important style.
LordZounds
Posts: 3
Joined: Sat May 28, 2016 5:36 pm

Re: Cannot block elements using a class starting with underscore

Post by LordZounds »

Alright, great. Thanks again!
tonylee123321
Posts: 1
Joined: Sun Apr 28, 2019 7:53 am
Contact:

Re: Cannot block elements using a class starting with underscore

Post by tonylee123321 »

I am testing my website but it is not effective. :cry:
Please check for me :

Code: Select all

https://365manga.net/
alicetaylor1
Posts: 1
Joined: Sat May 18, 2019 5:13 am
Contact:

Re: Cannot block elements using a class starting with underscore

Post by alicetaylor1 »

I know it's a matter of preference but can someone point to articles or the though process for these kind of patterns? Is there a move towards a particular convention or is there a popular set of convention people seem to agree/follow?
adamwood2444
Posts: 1
Joined: Thu Aug 29, 2019 6:44 pm
Contact:

Re: Cannot block elements using a class starting with underscore

Post by adamwood2444 »

same case for my site

Code: Select all

https://qrcodegenerator.org
Post Reply