Skip to content

Loading…

uBlock can be detected by checking the width of a blocked element #1418

Open
nyuszika7h opened this Issue · 12 comments

6 participants

@nyuszika7h

It appears to be possible to detect uBlock by simply checking if the blocked element's width 0.

OS: Windows 8.1
Browser: Firefox Beta 39.0
uBlock version: uBlock 0.9.4.5 Beta 1, uBlock Origin 0.9.8.2-rc.1

You can see a demonstration here. Make sure you have EasyList (or Fanboy's Ultimate List) enabled, or add the following filter manually:

-img/ads/

Update: It seems this also works with Adblock Plus.

@hairycactus

I have EasyList enabled in uBlock, & attempted the said demo. The result says: "You do not appear to be using an ad blocker."

So I assume I somehow passed the detection test. However, sites like Softpedia is able to detect uBlock at work. What detection method does it use ?

@nyuszika7h

Like I said, it just checks if the blocked element's width is 0. (You can just view the source of the script.) Apparently sometimes it gives false negatives, so try reloading, perhaps even Ctrl-Shift-R.

@hairycactus

Ok, I opened the demo page again (still negative result) & reloaded it once. The result is now in red: "You are using an ad blocker!"

But every time I restart the browser & revisit that page, it consistently gives a negative result, ie. unless I reload the page. Why do I consistently get a false-negative on every 1st attempt ?

it just checks if the blocked element's width is 0

Ah, I see. I'd been wondering how Softpedia goes about detecting uBlock. So how to make such detectors think that the width is not zero ? Substitute the blocked element with a 1-pixel transparent dummy element ? (This is a wild guess ... I am not trained in this subject matter.)

@nyuszika7h

Not sure why that false negative happens.

I think there's probably a way to pretend that the width of the element hasn't been changed, just like the display: none ! important; CSS rule uBlock adds is not visible to scripts loaded on the page.

@gorhill

Why do I consistently get a false-negative on every 1st attempt ?

Because the (generic) cosmetic filter is injected after the DOM of a page is loaded the first time. It's cached and thereafter it is injected before the DOM of the page finishes loading.

@lewisje

I don't believe there's a way for an extension to make CSS properties (like width and height and visibility and display, all of which can be inspected to infer an ad-blocker) look one way to the layout engine and another way to scripts on the page.

Also, to detect actual blocking, rather than just hiding, there are ways to tell whether a resource was loaded; for example, if it's a script, check for the existence of JS objects made by the script (NoScript allows for "surrogate scripts" to mitigate this problem).

@nyuszika7h

@lewisje uBlock actually does seem to hide display: none from the page's scripts already.

@lewisje

Do you mean that if a script runs getComputedStyle on a uBlock-hidden element, and pulls display out of that, it won't get 'none'?

@chrisaljoudi
Owner

@nyuszika7h @lewisje nope. I can't think of a reasonable way to collapse elements and still do that. I suggest turning off element collapsing from uBlock's preferences if you want to prevent pages from using that method.

@lewisje

I didn't think it was possible either, like it's possible to hide the added rule itself (I think that's what Shadow DOM is for) but not the fact that the element was collapsed.

@Betsy25

There are more ways apparently, This one is detecting it also (don't have the knowledge to spit out the "why") : http://www.chromeactions.com/magic-actions-for-youtube-volume-control.html

@gorhill

don't have the knowledge to spit out the "why"

It looks at whatever matches .adsbygoogle, a cosmetic filter in EasyList.

Disabling cosmetic filtering for the page prevents the warning.

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.