Greasy Fork is available in English.

removeFacebookSuggestedPosts

Remove facebook suggested posts and games

< Feedback on removeFacebookSuggestedPosts

Question/comment

§
Posted: 10.8.2016

Add in sponsored posts as well

Sponsored posts also show up in the feed, but don't always have the "Suggested" text in the span. I mucked around (js is not my first language FYI) and seemed to have made it work, but there's likely a way better way of doing it :)


DT.main = function(){
var spans = document.getElementsByTagName("SPAN");
var totalSpans = spans.length;
for(var i = 0; i < totalSpans; i++){
var item = spans.item(i);
if(item && item.textContent === 'Suggested Post'){
var parent = item.parentNode.parentNode.parentNode.parentNode.parentNode;
if(parent){
parent.parentNode.removeChild(parent);
console.log('Removed suggested post');
}
}
if(item && item.textContent === 'Sponsored'){
var parent2 = item.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode;
if(parent2){
parent2.parentNode.removeChild(parent2);
console.log('Removed sponsored post');
}
}
}
};


I watched in the console and did see the second check kick in, and didn't see one post that it should have removed, so seems successful? The number of nested div's that they use is just stupid, I counted as best I could and again I think I got it right, but who knows :)

§
Posted: 11.8.2016

Works but I just saw a 'suggested game' and condensed things a bit. I don't even know javascript so please adjust as necessary :smile: The game ad seems to be super rare so I am unable to verify that part works...

DT.main = function(){ var spans = document.getElementsByTagName("SPAN"); var totalSpans = spans.length; for(var i = 0; i < totalSpans; i++){ var item = spans.item(i); if(!item) return; if(item.textContent === 'Suggested Post' || item.textContent === 'Suggested Game' || item.textContent === 'Sponsored'){ var parent = item.parentNode.parentNode.parentNode.parentNode.parentNode; if(item.textContent === 'Sponsored') parent = parent.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode; if(parent){ parent.parentNode.removeChild(parent); console.log('Removed ' + item.textContent); } } } };

§
Posted: 11.8.2016

Cheers for the script additions guys! I will update the code and release a new version. It maybe a few days however as I'm now on holiday.

§
Posted: 11.8.2016
Edited: 11.8.2016

Thanks for this, those suggest posts were getting seriously annoying, but now, as previously mentioned, I saw the game suggestions right after enabling this. Looking forward to update that removes ALL those pesky ads. (like these https://i.gyazo.com/e21f3f8def26d87bad48f290dd53702a.png)
Thanks again.

§
Posted: 11.8.2016

I've just released v2 of this script, which should support removal of "Suggested Games". I've not been able to test it myself as I don't have these type of posts on my feed.

Let me know either way if this new version works for you.

Thanks again for the feedback.

§
Posted: 11.8.2016

So far, so good. Thanks for quick update/response.

§
Posted: 2.11.2017

Just created a new user script to remove sponsored posts: https://greasyfork.org/en/scripts/34722-removefacebooksponsoredposts

Post reply

Sign in to post a reply.