fb_under_the_hoodOn desktop I got tired of facebook always suggesting something. Whatever I clicked, commented or watched, there would come up some content asking for my attention. No! And all the people I could add as friends. No! And groups to join or create. No! And pages to like. No! And… Just no!

So I cooked up a userscript to address the issue. I use it with chrome with tampermonkey. Since privacy could be a concern, the script is self contained, does not go out of the DOM, does not send anything anywhere, does not call anything not on the page, so does not check for updates, nothing. Thus there is no way it could steal data.

It is important to know that facebook generates the pages with js, dynamically, and the code (class names, tree structure) is obscure and subject to change most of the time. So my script could become out of date even as I publish the most recent update. I wrote it for the English interface.

Use it at your own risk and responsability. And periodically check back for updates or check it on my github.

 

// ==UserScript==
// @name         facebook putzolo
// @namespace    //csillagtura.ro/less-facebook-suggestions-userscript
// @version      2016.08.28. 09:59
// @description  hides facebook dom elements like the annoying suggested posts/pages/people
// @author       VNP
// @match        https://www.facebook.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    
    //some extra css
    var css = '.carouselParent { display: none; } #GroupsRHCSuggestionSection { display: none; } #wekker { position: fixed; left: 0px; top: 0px; width: 10px; height: 10px;}';
    var head = document.head || document.getElementsByTagName('head')[0];
    var style = document.createElement('style');    
    style.type = 'text/css';
    if (style.styleSheet){
       style.styleSheet.cssText = css;
    } else {
       style.appendChild(document.createTextNode(css));
    }
    head.appendChild(style);
    
    //making the bar green, to show it's working
    var bb = document.getElementById("pagelet_bluebar");
    if (bb){
       var lista = bb.getElementsByTagName("div");
       for (var q=0; q < lista.length; q++){
              var a = lista[q].getAttribute("role");
              if (a!="dialog"){
                 if (
                       (lista[q].parentNode == bb) || 
                       (lista[q].parentNode.parentNode == bb) || 
                       (lista[q].parentNode.parentNode.parentNode == bb)
                    ){
                        lista[q].style.backgroundColor = "green";
                 }                   
              };
       };           
    };        
    
    /////setting up the interval that cleans the screen   
    setInterval(function (){
        var lista = document.getElementsByClassName("userContentWrapper");
        for (var q=0; q < lista.length; q++){
            if (lista[q].style.display!="none"){
              if (lista[q].innerHTML.indexOf("ponsored") > -1){
                  lista[q].style.display = "none";
              }
            };
        }
        var lista = document.getElementsByTagName("div");
        for (var q = 0; q < lista.length; q++){
            var a = lista[q].getAttribute("data-ownerid");
            if (a){
                a = String(a);
                if (a.indexOf("hyper") < 0){
                   var cn = " "+lista[q].className+" "; 
                   if (
                       (cn.indexOf(" uiContextualLayerPositioner ") < 0) && 
                       (cn.indexOf("Photo") < 0)
                      ){ 
                      if (lista[q].innerHTML != ""){ 
                         // lista[q].style.border = "5px solid orange";
                         lista[q].style.display = "none";
                      };    
                   };
                };
                
            }
        }
        
        //in the feed
        var lista = document.getElementsByTagName("div");
        for (var q =0; q -1){
                     lista[q].style.display = "none";
                  };
               }
            }  
        };             
        
        //sidebar on the right
        var lista = document.getElementsByClassName("ego_section");
        for (var q=0; q < lista.length; q++){
            if (lista[q].style.display!="none"){
                var s = lista[q].innerHTML.toLowerCase();
                if (
                     (s.indexOf("invite friends to like") > -1) ||
                     (s.indexOf("sponsored") > -1) ||
                     (s.indexOf("suggested pages") > -1) ||
                     (s.indexOf("sale groups") > -1) ||
                     (s.indexOf("suggested groups") > -1) ||
                     (s.indexOf("people you may know") > -1) ||
                     (s.indexOf("improve your news feed") > -1) ||
                     (s.indexOf("suggested people") > -1)
                   ){
                    lista[q].style.display = "none";
                }
            };
        }
    }, 1000);
})();
facebooktwittergoogle_plusredditpinterestlinkedinmail