Skip to content

Instantly share code, notes, and snippets.

@ouroborus
Created March 30, 2016 15:30
Show Gist options
  • Save ouroborus/e16eb9d9d5962e6dce57668cf83bc18a to your computer and use it in GitHub Desktop.
Save ouroborus/e16eb9d9d5962e6dce57668cf83bc18a to your computer and use it in GitHub Desktop.
Greasemonkey script to hide "Suggested post" entries on Facebook.
// ==UserScript==
// @name Hide "Suggested post" on Facebook
// @include https://www.facebook.com/*
// @grant none
// ==/UserScript==
(function(){
var watcher = function(){
var target=document.querySelector('div#stream_pagelet>div[id^="topnews_main_stream_"]>div[id^="feed_stream_"]');
if(target) {
var mangle=function(){
var x=document.querySelectorAll("div[data-testid=fbfeed_story]");
for(var i=0;i<x.length;i++){
if(x[i].querySelector(".uiStreamSponsoredLink")){
x[i].style.display="none";
}
}
};
mangle();
var observer=new MutationObserver(function(mutations){
mutations.forEach(function(mutation){
if(mutation.type=="childList"){
mangle();
}
});
});
observer.observe(target,{attributes:true,childList:true,characterData:true});
}
else {
setTimeout(watcher,100);
}
};
watcher();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment