Hide posts from those I'm not following in Facebook.

Get rid of those annoying posts from those i'm not following

22.04.2024 itibariyledir. En son verisyonu görün.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @namespace    https://greasyfork.org/en/users/1291782-tran-huu-phu-cuong
// @name         Hide posts from those I'm not following in Facebook.
// @version      1.1
// @description  Get rid of those annoying posts from those i'm not following
// @match        https://www.facebook.com/*
// @grant        none
// @Author       Cuong Tran
// @license MIT
// ==/UserScript==

//Whenever the page changes
(function() {
    function onElementInserted(containerSelector, elementSelector, callback) {
        var onMutationsObserved = function(mutations) {
            mutations.forEach(function(mutation) {
                if (mutation.addedNodes && mutation.addedNodes.length) {
                    [].map.call(mutation.addedNodes, function(el) {
                        if (!el || !el.querySelector) return;
                        // console.log('New inserted element', el)

                        if (el.attributes['data-pagelet'] && el.attributes['data-pagelet'].value === 'FeedUnit_{n}') {
                          callback(el)
                        } else {
                          var elements = el.querySelectorAll(elementSelector);
                          for (var i = 0, len = elements.length; i < len; i++) {
                            callback(elements[i]);
                          }
                        }
                    });
                }
            });
        };

        var target = document.querySelector(containerSelector);
        var config = { childList: true, subtree: true };
        var MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
        var observer = new MutationObserver(onMutationsObserved);
        observer.observe(target, config);
    }


    onElementInserted('body', 'div[data-pagelet="FeedUnit_{n}"]', function(element) {
        if(element.querySelector('div[role="button"]').innerHTML.contains('Follow')){
            element.firstChild.style.display = 'none';
            const newdiv = document.createElement('div');
            newdiv.innerHTML = `<div cmftsb="0"><div class="wbtn"><button>___</button></div><div class="wtxt">1 post hidden. Rule: UNFOLLOWING AUTHOR</div></div>`
            element.appendChild(newdiv);
        }
        // if (element.innerText.substring(0,2) !== 'Ad') return;
        // console.log(element);
        //    element.style.display = "none";
    });

})();