Facebook Remove Suggested and Sponsored Posts (Beta)

Remove Suggested for You and Sponsored posts (Beta)

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Facebook Remove Suggested and Sponsored Posts (Beta)
// @namespace    http://tampermonkey.net/
// @version      1.2
// @description  Remove Suggested for You and Sponsored posts (Beta)
// @author       Visualplastik
// @match        https://www.facebook.com/*
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js
// @grant        none
// ==/UserScript==



function gtfo() {

    //Remove Suggested for You
    $( "span:contains('Suggested for you')" ).parent().parent().parent().parent().parent().hide().next().hide().next().hide().next().hide();

    document.querySelectorAll('svg').forEach((el) => {
        if(parseInt(el.style.width.replace('px','')) + parseInt(el.style.marginRight.replace('px','')) > 54) {
            console.log('ad found');
           el.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.remove();
        }
    })
}

//Initial Run
setTimeout(function(){
    gtfo();
}, 3000);

//Repeat on Scroll
$( window ).scroll(function() {
  gtfo();
});