Created
March 30, 2016 15:30
-
-
Save ouroborus/e16eb9d9d5962e6dce57668cf83bc18a to your computer and use it in GitHub Desktop.
Greasemonkey script to hide "Suggested post" entries on Facebook.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==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