SlimSocial-for-Facebook icon indicating copy to clipboard operation
SlimSocial-for-Facebook copied to clipboard

Hide "suggested for you" posts and "you may like" cards

Open test2a opened this issue 1 year ago • 9 comments

  1. Suggested for you content. Would it be possible to hide these simply by checking if suggested for you keyword exists for a post ?

  2. People you may know or groups you may know. Can these cards be detected and hidden ?

test2a avatar Oct 26 '23 15:10 test2a

I think it can be easily implemented. Nice suggestions.

diesel701 avatar Jan 10 '24 16:01 diesel701

@diesel701

! Suggested for you
www.facebook.com##:is([aria-posinset],[aria-describedby]:not([aria-posinset])) div:not(:only-child)>div:only-child>div:only-child>div:first-child[class=""]>div:not([data-0]):has-text(/^Suggested/):upward([aria-posinset],[aria-describedby]:not([aria-posinset]))
! Unlabelled Suggested posts (with a Follow button)
www.facebook.com##:is([aria-posinset],[aria-describedby]:not([aria-posinset])) :is(h3,h4) [role=button]:has-text(Follow):upward([aria-posinset],[aria-describedby]:not([aria-posinset]))
! Use only if you actually have these: Suggested posts with the label next to the post date
www.facebook.com##:is([aria-posinset],[aria-describedby]:not([aria-posinset])):has-text(Suggested for you)
! People You May Know
www.facebook.com##:is([aria-posinset],[aria-describedby]:not([aria-posinset])) [aria-label="See all"][href="/friends/"]:upward([aria-posinset],[aria-describedby]:not([aria-posinset]))
! Suggested groups
www.facebook.com##:is([aria-posinset],[aria-describedby]:not([aria-posinset])) [aria-label="See more groups"][href="/groups/discover/"]:upward([aria-posinset],[aria-describedby]:not([aria-posinset]))
! Reels and short videos
www.facebook.com##:is([aria-posinset],[aria-describedby]:not([aria-posinset])) [aria-label="See more"][href="/reel/?s=ifu_see_more"]:upward([aria-posinset],[aria-describedby]:not([aria-posinset]))
! Suggested pages
www.facebook.com##:is([aria-posinset],[aria-describedby]:not([aria-posinset])) [aria-label="Suggested pages"]:upward([aria-posinset],[aria-describedby]:not([aria-posinset]))

---Mobile---
! Suggested for you (mobile)
m.facebook.com##[data-mcomponent="MScreen"]>div[class="m"]>div:has-text(Suggested for you)

these are working on ublock origin for me on desktop so maybe they can be adjusted for slimsocial?

shamirahim111 avatar Jan 10 '24 17:01 shamirahim111

@shamirahim111 I tried the last one for mobile with Firefox on Android but I got a glitchy behaviour of the scroll. Probably I will keep using SlimSocial with the "suggested" pages.

diesel701 avatar Jan 31 '24 11:01 diesel701

This would be a fantastic enhancement for a fantastic app.

adsarwal avatar Feb 29 '24 21:02 adsarwal

Facebook changed its code so I can't intercept the ads anymore.

Let's see if we get help from this other dev: https://github.com/zbluebugz/facebook-clean-my-feeds/issues/66

rignaneseleo avatar Apr 20 '24 06:04 rignaneseleo

Here's a snippet for hiding Sponsored posts on m.facebook.com:

function hideSponsoredPosts() {
  // -- dictionary of words to detect - must be in regex format.
  const DICTIONARY = new RegExp('Sponsored|Patrocinado|Gesponsert'.toLowerCase());

  // -- get collection of posts:
  posts = document.querySelectorAll('div[data-type="vscroller"] > div[data-mcomponent="MContainer"][data-tracking-duration-id]:not([hsp])');
  // -- scan each post for "Sponsored"
  posts.forEach( (post) => {
    // -- get the <element> that has the post's date/time/<certain phrases>
    const headerMeta = post.querySelector(':scope > div > div > div:nth-of-type(2) > div:last-of-type > div > span:first-of-type');
    if (headerMeta !== null) {
      // -- a typical post
      if (DICTIONARY.test(headerMeta.innerText.toLowerCase())) {
        // -- found a Sponsored post, hide it (do not remove - fb hates that!)
        post.setAttribute('data-actual-height', '0');
        post.style.height = '0';
        post.setAttribute('hsp', 'Sponsored');
      }
    }
  })
}

zbluebugz avatar Apr 24 '24 21:04 zbluebugz

Thanks for sharing but unforutunatly this doesn't seem to work on touch.facebook.com :(

rignaneseleo avatar Apr 25 '24 04:04 rignaneseleo

Is it possible to get a Windows10 browser to visit touch.facebook.com without being redirected to www.facebook.com?

zbluebugz avatar Apr 25 '24 06:04 zbluebugz

Is it possible to get a Windows10 browser to visit touch.facebook.com without being redirected to www.facebook.com?

I guess you need to change the User Agent to a mobile one

rignaneseleo avatar Apr 25 '24 07:04 rignaneseleo