Ads Blocker by FaB

Ads blocker for Facebook

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 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        Ads Blocker by FaB
// @namespace   sponsor_fb
// @description Ads blocker for Facebook
// @include     https://www.facebook.com/
// @version     1.1
// @grant       none
// ==/UserScript==


var k = 0;
window.onload = function () {
  window.addEventListener('scroll', function () {
    k++;
    if (k > 12) {
      for (var i = 0; i < document.all.length; i++)
      {
        if (document.all[i].tagName == 'SPAN') {
          if (document.all[i].innerHTML == 'Post consigliato') {
            document.all[i].innerHTML = 'Spoiler';
          }
          if (document.all[i].className == 'uiStreamAdditionalLogging _5paw _4dcu')
          {
            
            //modifico alcune scritte
            for (var j = 3; j < 7; j++) {
              
              document.all[i - j].innerHTML = 'Ads Blocked by FaB';
              document.all[i + j + 1].innerHTML = '';
            } 
            //modifico immagine  

            for (var j = 10; j < 15; j++) {
              //alert(j + ' ' + document.all[i - j].href);
              document.all[i - j].src = 'https://image.freepik.com/free-icon/facebook-logo_318-49940.jpg' 
            }
            //modifico il link dell'immagine e la card associata 

            for (var j = 10; j < 20; j++) {
              document.all[i - j].href = '';
              if (document.all[i - j].attributes[0].name == 'data-hovercard') {
                document.all[i - j].attributes[0].value = 'FaB'
              }
            }
          }
        }
      }
      k = 1;
    }
  });
}