KudoAmine / Hide Ads on Facebook

// ==UserScript==
// @name         Hide Ads on Facebook
// @namespace    https://tampermonkey.net/
// @version      1.16
// @description  Hide sponsored feeds on Facebook
// @author       KudoAmine
// @match        https://www.facebook.com/*
// @license MIT
// @grant        none
// ==/UserScript==

const HideAds = () => {
  const feeds = document.getElementById('contentArea').querySelectorAll('[id*=hyperfeed_story_id]');
  feeds.forEach(feed => {
    try {
            const feedtype = feed
        .querySelector('[data-testid*="test"]')
        .children[0];
      if ((feedtype.innerText.indexOf("Sponsor") != -1) || (feedtype.innerText.indexOf("مُم") != -1) || (feedtype.innerText.indexOf("Publicidad") != -1) || (feedtype.innerText.indexOf("Gesponsert") != -1) || (feedtype.innerText.indexOf("zato") != -1) || (feedtype.innerText.indexOf("cinP") != -1) || (feedtype.innerText.indexOf("Patrocinado") != -1) || (feedtype.innerText.indexOf("Được tài trợ") != -1) || (feedtype.innerText.indexOf("Реклама") != -1) || (feedtype.innerText.indexOf("赞助内容") != -1) || (feedtype.innerText.indexOf("贊助") != -1)) {
          feed.style.display = "none";
         // feed.setAttribute("Hideads", "hiddenfeedtype");
           }
        }
    catch (e) {
    }
        try {
          const sponsoredlink = feed
        .querySelector('[class="uiStreamSponsoredLink"]');
      if (sponsoredlink != undefined) {
        feed.style.display = "none";
       // feed.setAttribute("Hideads", "hiddensponsoredlink");
      }
        }
             catch (e) {
    }
          try {
        if (feed.innerHTML.indexOf("/ads/about?") != -1) {
     feed.style.display = "none";
          }
                 }
    catch (e) {
    }
                 
  });
}
HideAds()
setTimeout(HideAds, 1000);
(function () {

  window.addEventListener('scroll', () => {
    HideAds()
    setTimeout(HideAds, 1000);
  });


})();