removeFacebookSuggestedPosts

Remove facebook suggested posts and games

< 脚本removeFacebookSuggestedPosts的反馈

提问/评论

§
发表于:2016-08-10

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 :)

§
发表于:2016-08-11

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); } } } };

§
发表于:2016-08-11

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.

§
发表于:2016-08-11
编辑于:2016-08-11

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.

§
发表于:2016-08-11

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.

§
发表于:2016-08-11

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

§
发表于:2017-11-02

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

发表回复

登录以发表回复。