rignaneseleo / SlimSocial-for-Facebook

Light version of Facebook. Light both in the weight and in the use.
GNU General Public License v2.0
386 stars 74 forks source link

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

Open test2a opened 11 months ago

test2a commented 11 months ago
  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 ?

diesel701 commented 8 months ago

I think it can be easily implemented. Nice suggestions.

shamirahim111 commented 8 months ago

@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?

diesel701 commented 8 months ago

@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.

adsarwal commented 7 months ago

This would be a fantastic enhancement for a fantastic app.

rignaneseleo commented 5 months ago

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

zbluebugz commented 5 months ago

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');
      }
    }
  })
}
rignaneseleo commented 5 months ago

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

zbluebugz commented 5 months ago

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

rignaneseleo commented 5 months ago

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