Monday, July 15, 2013

Facebook...I thought you would know me better by now

For those who view facebook from a standard browser, I'm sure you are familiar with the right side column showing a lot of "recommendations" and sponsored sites. Sometimes these are good, but usually they just seem to be junk. In my case, I don't feel like seeing them anymore, so I wanted to play around with the site to make them go away. When you want to override websites on a permanent basis (not using the built in browser developer tools to edit/delete content), you can use Greasemonkey (firefox), or TamperMonkey (chrome). If you are using IE... first of all I'm sorry to hear that, but there is probably a greasemonkey version for that. Anyways, find the appropriate add-in for your browser and install it. There should be some management console for it or icon for it somewhere in your browser. For Chrome, it comes up as an icon in the top-right which looks like a black square with two grey circles at the bottom. Click there, add new script. You can use this script below and it should block most of these sponsored adds throughout the standard facebook pages.



// ==UserScript==
// @name       Facebook cleaner
// @version    0.1
// @description  Remove sidebar recommendations
// @match      http*://*.facebook.com/*
// ==/UserScript==


function hideIt(myObjToHide) {
    myObjToHide.style.visibility = 'hidden';
}
function cleanup() {
 var junkContent = document.getElementById('pagelet_ego_pane_w');
    if (junkContent != null) {
        junkContent.style.visibility = 'hidden';
  junkContent.onchange(hideIt(this));
    }

 var junkContent2 = document.getElementById('rightCol');
    if (junkContent2 != null) {
  junkContent2.style.visibility = 'hidden';
  junkContent2.onchange(hideIt(this));
    }
    
    var junkContent3 = document.getElementById('pagelet_ego_pane');
    if (junkContent3 != null) {
        junkContent3.style.visibility = 'hidden';
     junkContent3.onchange(hideIt(this));
    }
    var sponsorPopup = document.getElementsByClassName('ego_section');
    if (sponsorPopup != null) {
     for (i = 0; i < sponsorPopup.length; i++) {
            sponsorPopup[i].parentNode.removeChild(sponsorPopup[i]);
        }
   }
    var sponsorPopup2 = document.getElementsByClassName('ego_column');
    if (sponsorPopup2 != null) {
     for (i = 0; i < sponsorPopup2.length; i++) {
            sponsorPopup2[i].parentNode.removeChild(sponsorPopup2[i]);
        }
    }
}

cleanup;
setInterval(cleanup, 800);

//end of Script


Enjoy the cleaner experience in your social networking. Do note that this works as of 7/15/2013. Facebook may change their site in the future and rename tag ID's or class Name's which will cause this to break.

No comments:

Post a Comment