Element hiding exception rules don't seem to do anything

Posting here is no longer possible, please use the corresponding product forum.
Locked
auserofabp

Element hiding exception rules don't seem to do anything

Post by auserofabp »

I have been using element hiding to get rid of all hyperlinks to a certain website, but I would now like to allow links only to a specific page on that site. However, I seem to be unable to get element hiding exception rules to work. For testing purposes, I tried the following filters on http://adblockplus.org:

Code: Select all

##a
#@#a[href*="adblockplus"]
The result is that all links are hidden even if their href contains "adblockplus". It's as if the second rule weren't there. Am I doing something wrong, or is this a bug?
lewisje
Posts: 2743
Joined: Mon Jun 14, 2010 12:07 pm

Re: Element hiding exception rules don't seem to do anything

Post by lewisje »

There is no rule with the basic syntax of an element-hiding rule that serves as an exception rule; the closest you can get is an ordinary exception rule with the $elemhide option, which says "turn off element hiding on all pages matching the rule."

That is to say, there is nothing to complete the analogy "blocking rule is to exception rule as hiding rule is to..."
There's a buzzin' in my brain I really can't explain; I think about it before they make me go to bed.
auserofabp

Re: Element hiding exception rules don't seem to do anything

Post by auserofabp »

Then could you please explain to me what http://adblockplus.org/en/filters#elemhide_exceptions is talking about? I am using latest Adblock Plus (2.1) so this syntax is theoretically supported.
lewisje
Posts: 2743
Joined: Mon Jun 14, 2010 12:07 pm

Re: Element hiding exception rules don't seem to do anything

Post by lewisje »

I wasn't aware of that change in syntax; anyway, my guess now is that the "element-hiding exception" syntax is only supported with a domain specifier, like you could try these two rules instead:

Code: Select all

adblockplus.org##a
adblockplus.org#@#a[href*="adblockplus"]
Also, you should try updating to Adblock Plus 2.1.1; I read elsewhere on this forum that it's a good idea.
There's a buzzin' in my brain I really can't explain; I think about it before they make me go to bed.
auserofabp

Re: Element hiding exception rules don't seem to do anything

Post by auserofabp »

Tried those two rules under Adblock Plus 2.1.1 - same results as my first post. All the links are hidden.

Adblock Plus is clearly recognizing the #@# syntax to mean exception rule since it's green in the Filter Preferences dialog, but the rules seem to be getting completely ignored when ABP does the actual hiding. The element hiding exception rules aren't even getting hit.
Jett

Re: Element hiding exception rules don't seem to do anything

Post by Jett »

Bump!

This problem is still present. #@# syntax appears green, is even displayed in the list of filtered elements in current webpage, but still, it is ignored.

I tried:

Code: Select all

videofun.me#@#.textad
To fix the problem highlighted in this thread:
forum/viewtopic.php?f=2&t=16441


It doesn't work. Disabling ##.textad however does work. Is it a bug or is #@# just not meant to make element hiding exceptions ? If so then, what is ?


Thanks
Jett

Re: Element hiding exception rules don't seem to do anything

Post by Jett »

Note that

Code: Select all

~videofun.me##.textad
doesn't work any better :/
User avatar
Gingerbread Man
Posts: 1339
Joined: Fri Aug 12, 2011 5:28 am

Re: Element hiding exception rules don't seem to do anything

Post by Gingerbread Man »

auserofabp wrote:The result is that all links are hidden even if their href contains "adblockplus". It's as if the second rule weren't there. Am I doing something wrong, or is this a bug?
Do you mean the links at the top of this page ("Adblock Plus Homepage", "Board index", etc.)? Right-click one of them and choose Inspect Element. Note that their href attribute doesn't contain adblockplus. Therefore, the exception rule doesn't match, and the elements in question are hidden.

Links inside posts in threads, like "http://adblockplus.org" in your original post, do however, and they weren't hidden when I tested your filters.

You can also compose hiding filters with the :not pseudo-class. The effect is the same either way. The difference is purely cosmetic: you might prefer exceptions alongside the filters they apply to. Example:

Code: Select all

##a:not([href*="adblockplus"])
Jett wrote:To fix the problem highlighted in this thread:
forum/viewtopic.php?f=2&t=16441
That filter issue is supposed to have been fixed in EasyList several days ago. Manually update your filter lists. If the problem persists, post a link to the problematic page in the thread you mentioned.
Jett wrote:

Code: Select all

~videofun.me##.textad
doesn't work any better :/
That filter means, "block elements with the class textad, except on the videofun.me domain". It doesn't affect other filters, meaning ##.textad from EasyList will still hide matching elements on all sites.

Edit: Changed ##.TextAd to ##.textad. ID and class names in CSS are case-sensitive.
Jett

Re: Element hiding exception rules don't seem to do anything

Post by Jett »

Hi :)

Yes, my filters are up to date :)

I posted a sample link in the other thread as you asked.

That filter means, "block elements with the class textad, except on the videofun.me domain". It doesn't affect other filters, meaning ##.TextAd from EasyList will still hide matching elements on all sites.
Yes, that's exactly what I wanted to do, keep hiding .textad on every single site except videofun. The current workaround for that issue is to disable ##.textad, so I wanted to fine tune it but it doesn't work. ##.TextAd with caps isn't triggered, it's ##.textad only.


Thanks for the help :)
User avatar
Gingerbread Man
Posts: 1339
Joined: Fri Aug 12, 2011 5:28 am

Re: Element hiding exception rules don't seem to do anything

Post by Gingerbread Man »

Gingerbread Man wrote:Links inside posts in threads, like "http://adblockplus.org" in your original post, do however, and they weren't hidden when I tested your filters.
I can't seem to reproduce that anymore. Or put another way, I can reproduce the bug. I've tried various other rules with the same result whether they're general or domain-specific, tag-based, ID-based, class-based or attribute-based. Fresh profile with Adblock Plus 2.3.
To give a simpler example, the following two rules should have no effect because the second is an exception to the first.

Code: Select all

##img
#@#img[src]
Hiding rules with a :not pseudo-class exception do seem to work fine however, which was probably the source of my confusion. The following had no effect because it doesn't match anything (it's essentially an exception to itself).

Code: Select all

##img:not([src])
Jett wrote:I posted a sample link in the other thread as you asked.
I don't see any problem with the whitelist filter being applied there.
  1. The ##.textad filter in EasyList enabled, plus the following custom whitelist filter.

    Code: Select all

    videofun.me#@#.textad
    The Blockable Items pane shows the item in green text, marked with a circle. So the whitelist filter is in effect.
  2. The ##.textad filter in EasyList disabled, plus the following custom hiding filter.

    Code: Select all

    ~videofun.me##.textad
    The filter shows 0 hits and it doesn't show up in the Blockable Items pane, meaning it's not in effect.
If you want additional verification showing that the element isn't hidden, apply the following user style in Stylish. It'll show a small red rectangle with a message in the top left corner of the video.

Code: Select all

@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document domain("videofun.me") {

.textad {
  display: block !important;
  position: absolute !important;
  top: 0px !important;
  left: 0px !important;
  background: red !important;
  min-width: 200px !important;
  width: 200px !important;
  max-width: 200px !important;
  min-height: 50px !important;
  height: 50px !important;
  max-height: 50px !important;
}

.textad:after {
  content: 'div class="' attr(class)'"' !important;
  font: 12pt Arial !important;
}

}
Edit: Tweaked the user style a bit.
Jett

Re: Element hiding exception rules don't seem to do anything

Post by Jett »

I don't see any problem with the whitelist filter being applied there.
Well, the problem is that when I disable ##.textad in EasyList (with no custom filter), fullscreen works.

If I enable it but add a custom filter so it is disabled on videofun.me, don't you think fullscreen should work ? I mean why on earth wouldn't it, if setting an exception effectively means ##.textad is disabled for this specific website ?

Yet, fullscreen breaks. I really don't get it :mrgreen:


Thanks for Stylish. It sounds interesting but unfortunately in that case, verifying whether or not the element is hidden won't help. We already know when it is hidden by checking if going fullscreen fails. (Then either it is hidden or inexistent)
User avatar
Gingerbread Man
Posts: 1339
Joined: Fri Aug 12, 2011 5:28 am

Re: Element hiding exception rules don't seem to do anything

Post by Gingerbread Man »

Jett wrote:We already know when it is hidden by checking if going fullscreen fails. (Then either it is hidden or inexistent)
That's a false assumption. The user style above just makes the .textad element visible, for the sake of troubleshooting. The site sets it to be displayed out of view with height and width 5px and top and left -10px; the user style overrides this.

So if the element is made visible by the above user style, that means Adblock Plus didn't hide it. If it is hidden by Adblock Plus, then there's nothing for the user style to affect and there's no visible difference.

Image

I haven't sifted through the site's code so I don't know why only disabling the ##.textad filter in EasyList makes full screen work. It's why I referred you to the other thread, where the filter list maintainers could answer your question. Fanboy seems convinced it's a site issue. I'm trying to stick to the topic of this thread: whether or not element hiding exceptions fail to be applied.
Jett

Re: Element hiding exception rules don't seem to do anything

Post by Jett »

Thanks for taking the time to experiment.

I used Firefox's built-in "Inspector" to verify and the filter does work.

The only explanation I can think of right now is that the filter exception kicks in too late. i.e. EasyList's filter hides that element or postpones its creation, then the website javascript stores this fact into an adblock_detected boolean, and THEN the custom exception filter is ran and the element is displayed again.

That sounds odd, but ATM I don't see another explanation. Try to run "alert(adblock_detected);" in that page with our custom exception, you'll see it's set to true. Can *only* happen because of this:

Code: Select all

$(document).ready(function() {
    $("body").append("<div class='ad ads textad' style='position: absolute; top:-10px; left: -10px;width:5px;height: 5px;'></div>");
    var $ad = $(".textad");
    adblock_detected = ($ad.length==0 || $ad.is(":hidden") );
});
If this new explanation is correct then ABP could probably still use a fix to how/when it applies element hiding exception rules. That is why studying this website is IMO on topic.
If explanation incorrect, I don't see why adblock_detected is true. Nothing else sets the variable.
User avatar
Gingerbread Man
Posts: 1339
Joined: Fri Aug 12, 2011 5:28 am

Re: Element hiding exception rules don't seem to do anything

Post by Gingerbread Man »

Moved to Bug Reports.
Locked