Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

facebook.com #98

Closed
Uricorn opened this issue Aug 10, 2016 · 75 comments
Closed

facebook.com #98

Uricorn opened this issue Aug 10, 2016 · 75 comments

Comments

@Uricorn
Copy link

Uricorn commented Aug 10, 2016

URL(s) where the issue occurs

facebook.com

Describe the issue

Facebook is now showing ads for desktop users "who currently use ad blocking software."

Screenshot(s)

capture

Versions

  • Browser/version: Waterfox/47.0.1
  • uBlock Origin version: 1.8.4

Settings

capture

Notes

Only started noticing it today, also at least one other user reported the same issue. gorhill/uBlock#1886

@gorhill
Copy link
Member

gorhill commented Aug 10, 2016

I will need to reproduce to be able to figure what filter is needed. So far, I haven't been able to reproduce (it's a brand new account I created for that purpose). any hint on how to reproduce is welcomed.

@warthog3
Copy link

warthog3 commented Aug 10, 2016

Those posts can be blocked with the following filter:

facebook.com##:xpath(//*/a[@class='uiStreamSponsoredLink']/ancestor::div[contains(concat(' ',normalize-space(@id),' '),'hyperfeed_story_id_')])

Source: https://www.reddit.com/r/ublock/comments/4wye33/does_ublock_monitor_this_site_if_so_can_any/d6cdlei

@gorhill
Copy link
Member

gorhill commented Aug 10, 2016

Thanks @warthog3. I will try to understand the DOM layout for that ad according to your xpath:

div#hyperfeed_story_id_[...]
    [...]
        a.uiStreamSponsoredLink

If this is it, would this also work?

facebook.com##div[id^="hyperfeed_story_id_"]:has(a.uiStreamSponsoredLink)

@collinbarrett
Copy link
Contributor

@gorhill and @warthog3 both of your solutions seem to be effective. though I am not 100% confident in my ability to verify it will always work. the new Suggested Posts seem to show up near the top of the feed on every refresh, and with either of your rules added, I am not seeing them.

@collinbarrett
Copy link
Contributor

I am seeing it show up in uBlock's logger as blocking something with that filter on occassion. So, yes, I think it is working.

@gorhill
Copy link
Member

gorhill commented Aug 11, 2016

For those who can have these ads at will, to confirm it works is just a matter of toggling on/off cosmetic filtering in the popup panel -- they will be shown/hidden as one toggle off/on cosmetic filtering.

@gorhill
Copy link
Member

gorhill commented Aug 11, 2016

At this point it comes down to pick which selector runs most efficiently -- i.e. the one which will cause the smallest number of DOM elements to be visited internally by the browser's matching engine.

Does that work?

facebook.com###stream_pagelet div[id^="feed_stream"] > div[id^="substream_"] div[id^="hyperfeed_story_id_"]:has(a.uiStreamSponsoredLink)

@collinbarrett
Copy link
Contributor

@gorhill that last rule does not seem to work. the first two still do. not sure how to compare which is most efficient.

@gorhill
Copy link
Member

gorhill commented Aug 11, 2016

Ok, I see the DOM layout can vary a bit more than I expected. Try:

facebook.com###stream_pagelet div[id^="hyperfeed_story_id_"]:has(a.uiStreamSponsoredLink)

Edit: re-wrote it after a bit more thinking. There is probably no point trying to narrow more beyond #stream_pagelet in this case. Using #stream_pagelet should definitely help though, even for the xpath version.

@collinbarrett
Copy link
Contributor

@gorhill yes, that one seems to work. so, to summarize, any of the three below seem to be working for me. which would be more efficient?

facebook.com##:xpath(//*/a[@class='uiStreamSponsoredLink']/ancestor::div[contains(concat(' ',normalize-space(@id),' '),'hyperfeed_story_id_')])

facebook.com##div[id^="hyperfeed_story_id_"]:has(a.uiStreamSponsoredLink)

facebook.com###stream_pagelet div[id^="feed_stream_"] div[id^="substream_"] div[id^="hyperfeed_story_id_"]:has(a.uiStreamSponsoredLink)

@gorhill
Copy link
Member

gorhill commented Aug 11, 2016

I modified my comment above. For now, I will prefer the :has version. It will work declaratively whenever a browser supports it, and without any basis whatsoever I have the feeling it might be more efficient.

@gorhill
Copy link
Member

gorhill commented Aug 11, 2016

Taking into account the information gathered on reddit, and given your confirmation that it works, for now I will go with:

facebook.com###stream_pagelet div[id^="hyperfeed_story_id_"]:has(a.uiStreamSponsoredLink)

@Uricorn
Copy link
Author

Uricorn commented Aug 11, 2016

It works after I clicked the update filters button just now.

Thank you!

@collinbarrett
Copy link
Contributor

@gorhill it looks like EasyList implemented a different rule. not sure if having both rules hurts (since many users of uBlock are probably subscribed to both uAssets and EasyList)

https://adblockplus.org/blog/fb-reblock-ad-blocking-community-finds-workaround-to-facebook

@gorhill
Copy link
Member

gorhill commented Aug 11, 2016

Having both does not hurt -- like he is saying, Facebook may change a few things to make that filter stop working (especially with the bragging about it on a blog post directed at Facebook). On my side I still haven't been able to get any ads, so I rely completely on others to figure the DOM details of these ads.

@Uricorn
Copy link
Author

Uricorn commented Aug 16, 2016

I just got an ad in my feed, so I guess they found a way to get around it.

Edit: At the same time that was happening, Facebook was also sometimes having errors.
Now I don't see the ad when uBlock is active, and there are no errors. Might be related.

@gorhill
Copy link
Member

gorhill commented Aug 16, 2016

I just got an ad in my feed

Whoever get an ad in their feed, what helps is to provide the DOM details for that ad. Otherwise nobody can figure what filter could work.

@jcallen
Copy link

jcallen commented Aug 16, 2016

I just got an ad, and have some information on the DOM:

The class names all appear obfuscated (names like "_x72" and "5jmm"), but the outer <div> of the ad has an ID beginning with "hyperfeed_story_id" and contains a <div> that contains a <div> that contains a <div> that has class="... userContentWrapper ..." and contains a <div> that contains a <div> that contains a <span> without a class and with the exact content "Suggested Post"

The previous uiStreamSponsorLink class no longer is used, apparently replaced with a obfuscated name like "l_lkulvba5m" (and probably changes randomly).

@gorhill
Copy link
Member

gorhill commented Aug 17, 2016

with the exact content "Suggested Post"

Aren't ads supposed to be "Sponsored Post"?

@gorhill
Copy link
Member

gorhill commented Aug 17, 2016

I still do not have ads in my stream with cosmetic filtering disabled, however I have that annoying "People You May Know" box appearing all the time. I can make it go away with:

facebook.com##:xpath(//div[@id="stream_pagelet"]//div[starts-with(@id,"hyperfeed_story_id_")][.//text()="People You May Know"])

So the same can be done for "Suggested Post" for those who get them:

facebook.com##:xpath(//div[@id="stream_pagelet"]//div[starts-with(@id,"hyperfeed_story_id_")][.//text()="Suggested Post"])

And for "Sponsored":

facebook.com##:xpath(//div[@id="stream_pagelet"]//div[starts-with(@id,"hyperfeed_story_id_")][.//text()="Sponsored"])

However, this works for English Facebook, this would need to be adapted for other languages.

Edit: now I see in OP the image clearly shows that the ad has both "Suggested Post" and "Sponsored". So the last filter above would be the one to use. I will await confirmation it works.

@genev
Copy link

genev commented Aug 17, 2016

The filters in the previous comment work great for me, but would this block my friends' posts that include the word "Sponsored"?

@gorhill
Copy link
Member

gorhill commented Aug 17, 2016

but would this block my friends' posts that include the word "Sponsored"?

Yes, I though about that afterward -- try:

facebook.com##:xpath(//div[@id="stream_pagelet"]//div[starts-with(@id,"hyperfeed_story_id_")][.//h6//span/text()="Sponsored"])

Or, somebody tell me the ancestors of the "Sponsored" text -- I am assuming h6 is one of them (just like in 994985e).

@gorhill
Copy link
Member

gorhill commented Aug 17, 2016

By the way, what is the best way for one to see these ads? What specific feed do I need to activate? Currently using "News Feed"/"Most Recent". Is "Pages Feed" better if trying to get these ads?

@collinbarrett
Copy link
Contributor

Yeah, I'm having a hard time seeing any of them as of late, either. Last week when they first rolled them out I was seeing them a lot. Now, I don't see any in my feed or blocks of them in the uBlock logger... When I was seeing them, though, they were just in the standard News Feed almost always as like the 2nd or 3rd card down.

@gorhill
Copy link
Member

gorhill commented Aug 17, 2016

in the uBlock logger

On my side I find it easier to toggle on/off the no-cosmetic-filter switch to see what is being hidden by uBO. So far, I only got the "People You May Know" cards.

@JTBrinkmann
Copy link

Ads are personalised, so I guess it helps if Facebook knows a bit more about you and what you like. Maybe if you'd like some companies, you see more suggested posts?

@gorhill
Copy link
Member

gorhill commented Aug 17, 2016

Yes, I did "liked" stuff just for the sake of getting a feed with something in it. Currently tech news, science news. Maybe I should go with something more likely to generate ads. Clues?

@Uricorn
Copy link
Author

Uricorn commented Aug 17, 2016

Facebook might not be showing ads to you if your account is too new or you don't have enough friends. (They might have data suggesting that showing ads to those types of people causes people to use Facebook less or close their account.)

Some companies will try to aggressively target you if you visit their site a few times. https://www.invisionapp.com/ and https://www.intercom.io/ might be some of those sites.. not certain.

Either way I haven't seen any ads again, so maybe they were trying to test something but it broke the site.

@gorhill
Copy link
Member

gorhill commented Aug 17, 2016

Is that feed supposed to update itself regularly with new posts at the top? I can see the right-hand bar content change, but the feed itself seems to not change.

@yonjah
Copy link

yonjah commented Aug 18, 2016

This is firefox 48.0 using the builtin devtools

@gorhill
Copy link
Member

gorhill commented Aug 18, 2016

Ok, somehow I never realized the comments were visible in the DOM.

So how about:

facebook.com##:xpath(//div[@id="stream_pagelet"]//div[starts-with(@id,"hyperfeed_story_id_")][.//div[@data-reactroot]//button[@title="Remove"]])

I get no hit on my side, but then I have no ads in the first place.

@yonjah
Copy link

yonjah commented Aug 18, 2016

I'm still seeing some ads
new HTML http://pastebin.com/KvkzK3vY
also this rule seems to catch some genuine posts as well.

@lassekongo83
Copy link

lassekongo83 commented Aug 18, 2016

I don't use Facebook, but I took a quick look and noticed that 1 of their images still loads from slash ads. Maybe you could try something simple like this?
facebook.com##div[class^="userContentWrapper"]:has(img[src*="facebook.com%2Fads"])

Edit: From looking at a user script that removes the ads.
Also try: facebook.com##div[aria-label^="Story"]:has(a[href^="/about/ads"])

@neilmcd
Copy link

neilmcd commented Aug 18, 2016

They seem to have changed it back and the old rules are working again for me now. The uiStreamSponsoredLink class is back when inspecting the 'Sponsored' text.

@gorhill
Copy link
Member

gorhill commented Aug 18, 2016

Would ...

facebook.com##:xpath(//div[@id="stream_pagelet"]//div[starts-with(@id,"hyperfeed_story_id_")][.//span="Suggested Post"])

... also remove legit posts?

In any case, I will go through the cosmetic filtering engine and prepare for what Facebook may come up again if the problem resurface. This will not be next version though, rather the one after it. I already modified the new :matches-css selector to be able to "see" :after styles, now what is missing is the ability to allow more than one of these new operators into the same filter. That will be for another version, not 1.8.6.

@dxo
Copy link

dxo commented Aug 19, 2016

I'm getting the same result as neilmcd. The previous filter snippet has resumed working again. Thanks gorhill and those who contribute their time and efforts to this project and others like it.

@yonjah
Copy link

yonjah commented Aug 20, 2016

@gorhill The last rule you added seems to be working ok and doesn't remove any legit posts.

@taliarbel
Copy link

I'm a reporter doing a story for AP about ad blocking, and am interested in talking to people who write the filters that block ads -- would you want to explain the process to me and what motivates you? I'm at 212-621-7629 and tarbel@ap.org. Thanks, Tali

@gorhill
Copy link
Member

gorhill commented Aug 26, 2016

would you want to explain the process to me and what motivates you?

Aside all the obvious reasons (privacy invasion, malvertising, bloat, bandwidth, attempt at manipulation, bullshit, noise to signal ratio, etc.), blockers and filter lists help ensure user agents (i.e. browsers) keep working on behalf of users.

@taliarbel
Copy link

Could you talk on the phone for an interview?

-------- Original message --------
From: Raymond Hill notifications@github.com
Date: 8/26/16 12:40 PM (GMT-05:00)
To: uBlockOrigin/uAssets uAssets@noreply.github.com
Cc: "Arbel, Tali" TArbel@ap.org, Comment comment@noreply.github.com
Subject: Re: [uBlockOrigin/uAssets] facebook.com (#98)

would you want to explain the process to me and what motivates you?

Aside all the obvious reasons (privacy invasion, malvertising, bloat, bandwidth, attempt at manipulation, bullshit, noise to signal ratio, etc.), blockers and filter lists help ensure user agents (i.e. browsers) keep working on behalf of users.


You are receiving this because you commented.
Reply to this email directly, view it on GitHubhttps://github.com//issues/98#issuecomment-242786588, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AUPi83R5n0E_EXBeE-fInPcgvtrGyWuRks5qjxclgaJpZM4Jhkrp.

@IOUTODAY
Copy link

Just found you and your work - I would like to pick your brain on my efforts - ioutoday.org - if you don't mind and can spare a free minute I can be reached at jd@ioutoday.org

@gorhill
Copy link
Member

gorhill commented Aug 26, 2016

@taliarbel

Sorry, I do not give interview. The whole project is developed completely publicly, so whatever else is not answered by what is public here should be assumed to be private matter which I rather keep private.

@momphis
Copy link

momphis commented Aug 26, 2016

Are you looking for a deeper motivation other than what gorhill has already said? I can't speak for him, only as a user of his code. I use uBlock origin because my browser performs much better without ads, I'm at less risk of getting infected with malware, and it's easier to view the content I want to view. There's no deep, political reason for me: I just want to use the internet. uBlock origin makes it easier.

@taliarbel
Copy link

I'm not interested in motivation as much as process...is all the code open-source and unpaid, or does ublock origin have paid employees too? how hard is it to write filters that bypass walls and hide reinserted ads? how quickly do publishers react, if they do at all? do all these filters get automatically sent to all ublock origin users or is there individual tweaking that many people have to do?

@ghost
Copy link

ghost commented Aug 26, 2016

does ublock origin have paid employees too?

Paid with what money?
This thread is about the ongoing issue with facebook.com though. Just saying, not sure how @gorhill sees this.

@gorhill
Copy link
Member

gorhill commented Aug 26, 2016

It's all volunteer-based work, nobody is paid (it's a hobby).

How hard it is to create filter is a case-by-case basis, there is no generic answer. When it gets too difficult I take it as a sign it's time to extend the blocker capabilities. Probably best is to ask to those who spend a lot of time writing filters, the volunteers maintaining EasyList, EasyPrivacy and all other major filter lists.

Filter lists are updated automatically, so when a new filter is added, eventually everybody will have it. The goal is for the blocker to work seamlessly, requiring no tweaking by users -- but they can tweak however they want if they want to.

@taliarbel
Copy link

OK, but for example, with Facebook ads - a user would have to do more than simply install ublock to block those ads, no? that's what this whole message board is about?

@kosmonautbruce
Copy link

Tali, you will get a much better understanding of the process of development by familiarizing yourself with GitHub. All of the development of uBlock Origin is done very much out in the open, transparently. With some research, you can see it all, back to the beginning (almost).

gorhill's recommendation of going to the EasyList forum is a great one, if you want to see how that side of the equation occurs, as well, fwiw.

@gorhill
Copy link
Member

gorhill commented Aug 26, 2016

with Facebook ads - a user would have to do more than simply install ublock to block those ads, no?

Users are not supposed to do anything special. So far it appears the current filter is working[1], until people start to report that it does not, in which case this will have to be looked into.

[1] See above: "I'm getting the same result as neilmcd. The previous filter snippet has resumed working again."

@taliarbel
Copy link

well, for example for me, after downloading ublock to both firefox and chrome, i still see in-feed facebook ads today. i've not made any changes to the default version.

@gorhill
Copy link
Member

gorhill commented Aug 26, 2016

i still see in-feed facebook ads today

If one installs for the first time, the filter lists might not be up to date. They will update on their own within one hour, or you can force an update by visiting the "3rd-party filters" pane and clicking "Update now". That is a behavior specific to uBO, filter lists are never pulled from remote servers at launch time. Can't tell whether other blockers work this way.

@taliarbel
Copy link

Magic! Thanks. This discussion has been helpful. Again, if any of you would want to talk about the process behind this in more detail, I'm always available - tarbel@ap.org and at 212-621-7629. @gorhill, how do you extend the blocker capabilities? Are you limited in what you can do by the fact that you're not running an entire browser itself?

@dexiz
Copy link

dexiz commented Sep 4, 2016

@taliarbel
You would want to hear directly from gorhill, but it is hard for everyone to reveal one's weakness publicly.

In my opinion, any adblock browser extensions shares the limitation: video ads. Why is it so easy to remove facebook sponsored ads? Because this is about element hiding. If element hiding is the matter, one can write a javascript code to block them, and if something is possible with javascript, it can be implemented to blockers, too.
This is also why many anti-adblock solutions fail. Most of them are relying on detecting hidden elements, which can simply nullified by un-hiding them.

Video ads are different. This is about url blocking, among two things that blockers do. Video ads can't just be hidden via element hiding rules as otherwise it will hide the main video too. Also, video ads are more closely related to the main content, so it's possible to make it hard to distinguish ads and the main content, or it can stop users if the video ads content is not downloaded to the browser, to which you can even use Subresource Integrity.
Currently there are some anti-adblock solutions which detects url blocking, but they all try to load some stuffs that are not necessarily needed to the page, so it can just be unblocked, or they uses a separate script for it which can be blocked by some blockers like ubo.
Think about hulu.com - it has claimed long before that their video ads are unblockable, and it is still true.

@collinbarrett
Copy link
Contributor

Facebook must have changed something recently. I am seeing sponsored posts again in my timeline as of a couple days ago. Here's a screenshot. I am using uBlock Origin's Wiki "Hard Mode" with a few additional lists as well as Reek's AAK userscript.

pic_censored

@gorhill
Copy link
Member

gorhill commented Dec 19, 2016

Do the filters suggested at #233 work?

@karbassi
Copy link

@gorhill Can confirm that #233 works until FB changes things again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests