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 #3367

Open
GetGankNow opened this Issue Aug 30, 2018 · 149 comments

Comments

Projects
None yet
@GetGankNow
Copy link

GetGankNow commented Aug 30, 2018

URL(s) where the issue occurs

Facebook.com

Describe the issue

The Facebook sponsored ads is appearing again, i have tried all the solutions but nothing works

Versions

  • Browser/version: [Chrome 68.0.3440.106]
  • uBlock Origin version: [1.16.18]

Settings

  • [Default]
@KiLL4FuNK

This comment has been minimized.

Copy link

KiLL4FuNK commented Aug 30, 2018

I see nothing Can it be adware?
you have to see what programs you installed any
check if you do not have some rare extensions

@GetGankNow

This comment has been minimized.

Copy link

GetGankNow commented Aug 31, 2018

No i don't have any adware or some adware extensions, the ads are from Facebook ( sponsored )

@mapx-

This comment has been minimized.

Copy link
Contributor

mapx- commented Aug 31, 2018

While on a page with ads, right click on page, save as ..., you'll get a folder + html page, zip them together, upload the zip on some free server. Post here the link.

@GetGankNow

This comment has been minimized.

Copy link

GetGankNow commented Aug 31, 2018

Here the page with the sponsored ad: https://ufile.io/y827j

@mapx-

This comment has been minimized.

Copy link
Contributor

mapx- commented Aug 31, 2018

@GetGankNow test this filter
facebook.com##.userContentWrapper :has([id^="feed_subtitle_"]:has-text(Sp))

@GetGankNow

This comment has been minimized.

Copy link

GetGankNow commented Aug 31, 2018

@mapx- is blocking all post but allowing the comment section and reaction section.

@mapx-

This comment has been minimized.

Copy link
Contributor

mapx- commented Aug 31, 2018

facebook.com###substream_1:has([id^="feed_subtitle_"]:has-text(Sp))

@GetGankNow

This comment has been minimized.

Copy link

GetGankNow commented Aug 31, 2018

@mapx- works bro, thanks a lot.

@GetGankNow

This comment has been minimized.

Copy link

GetGankNow commented Aug 31, 2018

Edit: some sponsored ads are appearing again.

@mapx-

This comment has been minimized.

Copy link
Contributor

mapx- commented Aug 31, 2018

another example page ?

@GetGankNow

This comment has been minimized.

Copy link

GetGankNow commented Aug 31, 2018

The page that i save include all ads, i don't know how to save the page without the ads of this: facebook.com###substream_1:has([id^="feed_subtitle_"]:has-text(Sp))

@GetGankNow

This comment has been minimized.

Copy link

GetGankNow commented Aug 31, 2018

facebook.zip
Here the page again.

@mapx-

This comment has been minimized.

Copy link
Contributor

mapx- commented Sep 1, 2018

test

facebook.com##[id^=hyperfeed_story_id_]:has(a[href*="client_token"])
facebook.com##[id^=hyperfeed_story_id_]:has(a[href*="utm_campaign"])

@uBlockOrigin uBlockOrigin deleted a comment from adranger Sep 1, 2018

@GetGankNow

This comment has been minimized.

Copy link

GetGankNow commented Sep 1, 2018

@mapx- this 3 rules works. Thanks for all!!

@mapx- mapx- closed this in d1b91d6 Sep 1, 2018

ZaphodBeebblebrox added a commit that referenced this issue Sep 1, 2018

mapx- added a commit that referenced this issue Sep 6, 2018

@ghajini

This comment has been minimized.

Copy link

ghajini commented Sep 9, 2018

ads 'sponsored'

screenshot 41c

@mapx-

This comment has been minimized.

Copy link
Contributor

mapx- commented Sep 9, 2018

test
facebook.com##[id^=hyperfeed_story_id_]:has([id^=u_fetchstream_2_1]:has-text(SpSonSsoSredS))
or
facebook.com##[id^=hyperfeed_story_id_]:has([id^=u_fetchstream_2_1]:has-text(Sp))

@ghajini

This comment has been minimized.

Copy link

ghajini commented Sep 9, 2018

not working bro
screenshot 42

@mapx-

This comment has been minimized.

Copy link
Contributor

mapx- commented Sep 9, 2018

weird, working for me (exactly using your test-case)

Did you test the same case you uploaded ? or something new ? could be "they" are using different approaches

@shuhaowu

This comment has been minimized.

Copy link

shuhaowu commented Sep 10, 2018

Doesn't work for me either. I had to use something like this:

facebook.com##[id^=hyperfeed_story_id_]:has([id^=feed_subtitle_]:has-text(SpSonSsoSredS))

However, with this filter active, FB seems to be refreshing the posts in an infinite loop.

@filbo

This comment has been minimized.

Copy link

filbo commented Sep 13, 2018

From about 3mo to about 2wk ago, it was possible to catch Sponsored posts with :has-text(SpSonSsoSredS). This appeared only in Sponsored posts, with the 'S' elements hidden by CSS. (I'm not sure about back then, but now, the hiding CSS uses 'font-size:0', not 'display:none'.)

About 2wk ago, they started putting that stuff into all(*) posts. In Sponsored posts they use CSS to hide the 'S' elements. In 'normal' posts they use CSS to hide all of this. :has-text() is not aware of CSS hiding. The CSS used for this hiding is cryptographically hashed; so far it has remained stable for me, but another user has completely different classes, so the simple selector I use in my own filter won't work for anyone else. So we have to get into runtime evaluation of CSS computed styles :(

[(*)Not really 'all', but all normal posts by users, and many Sponsored posts, although some emitted by other modules inside FB don't use this particular trickery.]

It seems like uBO :matches-css() [see: https://github.com/gorhill/uBlock/wiki/Procedural-cosmetic-filters] might be able to handle this. Something like:

facebook.com##[id^=hyperfeed_story_id_]:if([id^=feed_subtitle_] span:has-text(^Sp$):matches-css(:not(display:none)))

-- which is COMPLETELY UNTESTED, just a pile of syntax smashed together by hand. Not sure if the nested uBO selectors are supported...

And all they need to do to break this is chop the word 'Sponsored' up differently; and it won't work for other UI languages. This is getting ugly.

@kowith337

This comment has been minimized.

Copy link

kowith337 commented Sep 13, 2018

Maybe need to view the deep of they DOM tag, e.g. looking in data-ajaxify, data-sigil, data-uri, data-ft, data-xt, ...

for example, I've found some part of sponsored URLs have is_sponsored=1 parameter, sometime it's boxed the parameter like [is_sponsored]=1

@wtchangdm

This comment has been minimized.

Copy link

wtchangdm commented Sep 13, 2018

Hi, I saw the comment in filters so I'd like report here:
I am not sure if is region-related, but the following rule is killing my timeline (using https://www.facebook.com/?sk=h_chr). All of the posts are hidden now.

facebook.com##[id^=hyperfeed_story_id_]:has([id^=feed_subtitle_]:has-text(SpSonSsoSredS))

Thanks.

mapx- added a commit that referenced this issue Sep 13, 2018

@terrorist96

This comment has been minimized.

Copy link
Contributor

terrorist96 commented Dec 10, 2018

@terrorist96

  • so, with the existing filters you still get sponsored ads.
  • could you save the page with ads (page + folder => zip them together) and send the zip (or the link) to this email
    axis.trivia@gmail.com ?

Yes. I've been seeing ads on Facebook for many weeks now. I'll send you an email later today. Thanks.

@mohamedmansour

This comment has been minimized.

Copy link

mohamedmansour commented Dec 10, 2018

So theoretically, this uBO filter should work?

facebook.com##div[id^="hyperfeed_story_id_"]:has(a[role="link"]:if-not(:scope:matches-css(display: none)))

Yes, in my fblock extension, that is what I do, it looks like the following. I match the first role from each article, so in ublock need to get the article match.
image

This is all error prone, with the incremental deployments that Facebook does once every day, they could change the classnames. The best to do is just delete Facebook. uBlock should add a Header stating

Facebook is an unethical company which wants to own your own data, and show you ads without any way of removing them, even if we wish to pay, #deletefacebook

@mapx-

This comment has been minimized.

Copy link
Contributor

mapx- commented Dec 10, 2018

@terrorist96 if are you who sent me the zip, I tested it and already works with the filters in ublock filters.
Could you update the lists and test again ?

@terrorist96

This comment has been minimized.

Copy link
Contributor

terrorist96 commented Dec 10, 2018

@mapx- yes it was me. I just updated my filters and I still see the sponsored ad on the right column but don't see sponsored stories on the feed.

@mapx-

This comment has been minimized.

Copy link
Contributor

mapx- commented Dec 10, 2018

ok, for the right sponsored test
facebook.com,facebookcorewwwi.onion##.ego_section:has(a[href*="/ad___campaign"])
or
facebook.com,facebookcorewwwi.onion##.ego_section:has(a[href*="campaign_id"])

mapx- added a commit that referenced this issue Dec 10, 2018

@jameshilliard

This comment has been minimized.

Copy link

jameshilliard commented Dec 10, 2018

I wonder if a blocking approached based on aria labels or other accessibility features would work better since those are required to be machine readable which could prevent facebook from effectively obfuscating them.
See:
https://www.facebook.com/help/accessibility
https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA

@terrorist96

This comment has been minimized.

Copy link
Contributor

terrorist96 commented Dec 10, 2018

ok, for the right sponsored test
facebook.com,facebookcorewwwi.onion##.ego_section:has(a[href*="/ad___campaign"])
or
facebook.com,facebookcorewwwi.onion##.ego_section:has(a[href*="campaign_id"])

They both work. Please merge at least one. Thanks!

@mapx-

This comment has been minimized.

Copy link
Contributor

mapx- commented Dec 10, 2018

They both work. Please merge at least one. Thanks!

yeah, already done above, thanks for sending the test case

@filbo

This comment has been minimized.

Copy link

filbo commented Dec 10, 2018

further inevstigate whether the a[role="link"] part can be made more specific so as to reduce the set of nodes for which :if-not() will be executed.

This is not necessary as there is a maximum of one a[role="link"] per FB post.

The expression given above was backwards; and should include the onion site. Try:

facebook.com,facebookcorewwwi.onion##div[id^="hyperfeed_story_id_"]:has(a[role="link"]:if(:scope:matches-css(display: none)))

@filbo

This comment has been minimized.

Copy link

filbo commented Dec 10, 2018

As I read it, it seems like the original should be correct and my 'backwards' one should be wrong. But when tested, in practice, it works as I said. The original (from @gorhill, ~7 hours back) causes all posts except ads to be hidden; this one hides only ads.

@filbo

This comment has been minimized.

Copy link

filbo commented Dec 10, 2018

BBC might note that github usernames are clickable links which may lead to a person's real name; and that it is frustrating to see an article with no byline, feedback button, or comments area.

@terrorist96

This comment has been minimized.

Copy link
Contributor

terrorist96 commented Dec 10, 2018

facebook.com,facebookcorewwwi.onion##div[id^="hyperfeed_story_id_"]:has(a[role="link"]:if(:scope:matches-css(display: none)))

To test, I disabled uBlock filters, confirmed ads on facebook, then tried your code, and I see both feed and right column ads. Unless it relies on other code in uBlock filters that is disabled, that code doesn't work on my end.

@filbo

This comment has been minimized.

Copy link

filbo commented Dec 11, 2018

Oh frick, I didn't disable the rest of uB filters when I tested that, may well have been tricked.

I did test that gorhill's version (with ':not-has()') hid 100% of all posts.

He's far more expert at uB filter language than I am. The concept we're trying to capture is:

on facebook.com,facebookcorewwwi.onion,
for each div[id^="hyperfeed_story_id_"],
if it has an a[role="link"] which is hidden,
it's an ad (and should be trimmed at the hyperfeed_story_id point)

@jameshilliard

This comment has been minimized.

Copy link

jameshilliard commented Dec 11, 2018

I think I came up with a much better way to prevent facebook from breaking the filters, see my code here(it's kinda hacky but should be a decent proof of concept) which adds the new :has-visible-text filter.

It uses a recursive parser to extract only visible text from child elements, here's an example filter that goes with it:

facebook.com,facebookcorewwwi.onion##div[id^="hyperfeed_story_id_"]:has(div[id^="feed_sub_title_"]:has-visible-text(Sponsored))
@terrorist96

This comment has been minimized.

Copy link
Contributor

terrorist96 commented Dec 11, 2018

facebook.com,facebookcorewwwi.onion##div[id^="hyperfeed_story_id_"]:has(div[id^="feed_sub_title_"]:has-visible-text(Sponsored))

To test, I disabled uBlock filters, confirmed ads on facebook, then tried your code, and I see both feed and right column ads. Unless it relies on other code in uBlock filters that is disabled, that code doesn't work on my end.

@jameshilliard

This comment has been minimized.

Copy link

jameshilliard commented Dec 11, 2018

@terrorist96 You'll need to check out this branch as the filter relies on the new has-visible-text method I added there. The proof of concept filter is currently only tested against feed posts but it should be fairly straight forward to adapt to the sidebar posts.

@terrorist96

This comment has been minimized.

Copy link
Contributor

terrorist96 commented Dec 11, 2018

Ok I'll test again if that gets approved/merged and the extension update is pushed out.

@jameshilliard

This comment has been minimized.

Copy link

jameshilliard commented Dec 11, 2018

I've uploaded a chromium test build here which can be installed manually if you want to try it.

@terrorist96

This comment has been minimized.

Copy link
Contributor

terrorist96 commented Dec 11, 2018

I've uploaded a chromium test build here which can be installed manually if you want to try it.

Ok just tested it. Confirm that it blocks the feed ad, but not the sidebar ad (as expected). Very cool!

@jameshilliard

This comment has been minimized.

Copy link

jameshilliard commented Dec 11, 2018

Cool, the technique I came up with works by recursively walking all the elements below the target node while pulling the computed style for each individual node, if it comes across a node with a style identifier that will cause that node to not be visible it simply skips that node and any children. Since facebook seems to sometimes use parent nodes to hide children this technique appears to filter out the false positive traps they have(there may potentially be other styles that hide nodes that I've missed but those should be fairly straight forward to add and facebook will likely eventually run out of them).

@filbo

This comment has been minimized.

Copy link

filbo commented Dec 13, 2018

@jameshilliard that approach can work. There are a number of concerns:

  • it's a fairly expensive JavaScript exercise you're wanting to conduct on potentially a lot of divs below 'feed subtitle'

  • varied hiding techniques: I've already seen them use 'display:none' and 'font-size:0px' (or equivalent). I can imagine others, like giving them a large negative position, or who knows what else. Same color foreground and background, coupled with negative kerning to pull up the gaps?

  • is your evaluation anchored below the starting point or below the entire HTML page? I'm working in an environment where we hide individual posts -- not permanently, but as a matter of dividing them up into 'tabs' according to search criteria. If your evaluation is anchored at the top of the DOM, you will see every single shred of one of those hidden posts as ... hidden. No useful 'sponsored / not sponsored' determination can be made. However, if your evaluation is anchored at the top of the post (<div._5jmm> with id like 'hyperfeed_story_id_gibberish' [except that can vary in different contexts]) -- then this approach will succeed. Um. It would have to ignore the display attribute of that top div._5jmm, which is exactly where we hide / show the post.

@jameshilliard

This comment has been minimized.

Copy link

jameshilliard commented Dec 13, 2018

it's a fairly expensive JavaScript exercise you're wanting to conduct on potentially a lot of divs below 'feed subtitle'

Yeah, I'm not really sure if there's a more efficient alternative, at least this filter can be targeted at only nodes that actually require it. Facebook will likely stop using this obfuscation method if it becomes ineffective.

varied hiding techniques: I've already seen them use 'display:none' and 'font-size:0px' (or equivalent).

I think this method should catch both of those at least.

I can imagine others, like giving them a large negative position

That may be tricky for them to pull off on these elements due to where they are being anchored, I expect this will go through a few rounds of cat and mouse with facebook before they run out of ideas. It should at least be much more effective than the current blocking methods since they can trivially randomize various identifiers.

is your evaluation anchored below the starting point or below the entire HTML page?

The recursive function does evaluation on each feed_sub_title_ node but hides the parent hyperfeed_story_id_ node.

@filbo

This comment has been minimized.

Copy link

filbo commented Dec 13, 2018

The recursive function does evaluation on each feed_sub_title_ node but hides the parent hyperfeed_story_id_ node.

Right, that's as expected. My question is ... I don't know if I know the right terminology. Suppose I've already set the hyperfeed_story_id node to display:none (but it's temporary and I provide a user interface for users to toggle it). When you evaluate whether some deep sub-node is display:none (or otherwise hidden), are you tricked by my outer display:none? I suspect yes, if you're using getComputedStyle(). You would have to use a private implementation which is able to anchor its evaluation below that node, for it to be otherwise.

Or, I would have to somehow figure out how to coordinate so that my processing runs after ad blockers'. hmmm.

@jameshilliard

This comment has been minimized.

Copy link

jameshilliard commented Dec 13, 2018

If a parent node is display:none all child nodes would not be visible right?

@filbo

This comment has been minimized.

Copy link

filbo commented Dec 13, 2018

Yes of course. But, besides the extension I work on toggling on and off individual posts, FB's own code plays all sorts of shenanigans with the display property of individual posts and tranches of posts. If you're evaluating things on a basis of visibility when FB has hidden everything, you will be tricked in either false-positive or false-negative direction. Maybe your processing always gets in before the FB foolery.

@okiehsch okiehsch pinned this issue Dec 14, 2018

@okiehsch okiehsch unpinned this issue Dec 14, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment