Page 1 of 1

Cannot block elements using a class starting with underscore

Posted: Wed May 25, 2016 2:31 am
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!

Re: Cannot block elements using a class starting with underscore

Posted: Wed May 25, 2016 8:38 am
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;">

Re: Cannot block elements using a class starting with underscore

Posted: Thu May 26, 2016 12:06 am
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?

Re: Cannot block elements using a class starting with underscore

Posted: Thu May 26, 2016 12:17 am
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.

Re: Cannot block elements using a class starting with underscore

Posted: Thu May 26, 2016 1:39 am
by seanb
Okay, thanks a lot!

Re: Cannot block elements using a class starting with underscore

Posted: Sat May 28, 2016 5:41 pm
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?

Re: Cannot block elements using a class starting with underscore

Posted: Sat May 28, 2016 6:43 pm
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)

Re: Cannot block elements using a class starting with underscore

Posted: Sat May 28, 2016 6:52 pm
by LordZounds
mapx, that worked perfectly, thanks a lot!

Can using that script and ignoring the !important keyword cause any problems on other sites?

Re: Cannot block elements using a class starting with underscore

Posted: Sat May 28, 2016 7:07 pm
by mapx
Not as far as I know, they are only enforcing those elements using !important style.

Re: Cannot block elements using a class starting with underscore

Posted: Sat May 28, 2016 7:09 pm
by LordZounds
Alright, great. Thanks again!

Re: Cannot block elements using a class starting with underscore

Posted: Sun Apr 28, 2019 8:08 am
by tonylee123321
I am testing my website but it is not effective. :cry:
Please check for me :

Code: Select all

https://365manga.net/

Re: Cannot block elements using a class starting with underscore

Posted: Sat May 18, 2019 5:17 am
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?

Re: Cannot block elements using a class starting with underscore

Posted: Thu Aug 29, 2019 6:51 pm
by adamwood2444
same case for my site

Code: Select all

https://qrcodegenerator.org