Facebook Filter Fork

Minimizes all posts your friends didn't post

目前为 2017-02-21 提交的版本。查看 最新版本

// ==UserScript==
// @name         Facebook Filter Fork
// @namespace    thetom.facebook
// @version      1.7.5
// @description  Minimizes all posts your friends didn't post
//               (friend liked, friend commented, friend attends...)
// @author       TheTomCZ <[email protected]> (Original Author)
// @author       <[email protected]> (Maintainer of this fork)
// @match        https://www.facebook.com/*
// @require      https://code.jquery.com/jquery-2.1.4.min.js
// @grant        none
// @homepage     https://gf.qytechs.cn/en/scripts/27554-facebook-filter-fork
// ==/UserScript==

$(function() {
    'use strict';
	const timesToFilter=5, timeoutBetweenFilters=250;
	const whitelistSelf=true;//posts with a link to your profile
    const keywordsPostDescription = [
		// comment out anything you want to not be filtered
        " was tagged in ",
        " was mentioned in ",
        " likes ",
        " liked ",
        " replied to a ",
        " commented on ",
        " now friends",
        " followed ",
        " is interested in an event",
        " going to an event",
        " others wrote on ",
        "'s Birthday",
        " reacted to this",

        /*Change the '/' to '//' if you us Facebook in Czech
        " se líbí ",
        " se líbí uživateli ",
        " tady odpověděl",
        " okomentovali uživatelé",
        " okomentovali příspěvek ",
        " to okomentoval",
        " is now friends with ",
        " má zájem o událost",
        " má narozeniny",
        " na to zareagoval(a)",
        " se zúčastní události",//*/
    ];
    const keywordsBanned = [
		//these are banned from showing up anywhere in the post
		//change these to something personal
        "Trump",
        "Obama",
        "Biden",
        "Clinton",
        "Sanders",
        "Jesus",
        "People you may know",
    ];
	//customize variables above

    const profileHref=document.querySelector('a[data-testid="blue_bar_profile_link"]').href;
    prepare();
    filterAll();
    $(document).on('scroll',filterAll);

    function prepare(){
        /*jshint multistr: true */
        $("head").append("\
            <style>\
            .filteredOut .userContentWrapper > div:first-child > .userContent + div, .filteredOut ul{       \
                display: none!important;          \
            }                                        \
            .filteredOut {                            \
                opacity: 0.5!important;                                             \
                padding: 0px!important;                                             \
                margin: 3px 0!important;                                             \
            }                                                    \
            .filteredOut h5 {\
                font-size: 12px!important;                    \
                margin-top: -2px!important;                           \
                padding: 3px!important;                           \
            }\
            .filteredOut .commentableItem, .filteredOut img, .filteredOut .userContentWrapper form, .filteredOut h5 + div{\
                display: none!important;                         \
            }\
            .filteredOut ._1dwg{\
                display: block!important;\
            }\
            .filteredOut .userContent+div{  \
                display: none!important; \
             }   \
            .filteredOut .stat_elem{\
                display: none!important;\
            }\
            .filteredOut *{\
                height: auto!important;\
                padding: 0!important;\
                margin: 0!important;\
            }                       \
            </style>"
       );
    }

    function minimize($elem){
        var id = $elem.attr("id");
        $elem.find("h5").append(" <a id='showStory_"+id+"'>unhide</a><a id='rehideStory_"+id+"' style='display:none'>rehide</a>");
        hideStory(id);
        $("#showStory_"+id).click(function(){showStory(id);});
        $("#rehideStory_"+id).click(function(){hideStory(id);});
    }

    function showStory(id){
        $("#rehideStory_"+id).show();
        $("#showStory_"+id).hide();
        $("#"+id).removeClass("filteredOut");
    }

    function hideStory(id){
        $("#rehideStory_"+id).hide();
        $("#showStory_"+id).show();
        $("#"+id).addClass("filteredOut").addClass("fbSpam");
    }

    function filter(index,elem){
        if(!$(elem).attr){
            return;
        }
        var $elem = $(elem);
        if($elem.hasClass("fbFiltered") || !$elem.attr("id")){
            return;
        }
        if($elem.attr("id").substring(0,16)!=="hyperfeed_story_"){
            return;
        }
        setTimeout(function(){_filter($elem,timesToFilter);},0);
    }
    function _filter($elem,times){
        if($elem.hasClass("fbSpam")){
            return;
        }
        $elem.addClass("fbFiltered");
        const elemInnerHTML=$elem.context.innerHTML;
        if(elemInnerHTML.includes(profileHref)){
            return;
        }
        for(var j in keywordsBanned){
            if(elemInnerHTML.includes(keywordsBanned[j])){
                minimize($elem);
                return;
            }
        }
        var title = $elem.find("h5").text();
        for(var i in keywordsPostDescription){
            if(title.includes(keywordsPostDescription[i])){
                minimize($elem);
                break;
            }
        }
        title = $elem.find("div._5g-l").text();
        for(i in keywordsPostDescription){
            if(title.includes(keywordsPostDescription[i])){
                minimize($elem);
                break;
            }
        }
        if(times>1){
            setTimeout(function(){_filter($elem,times-1);},timeoutBetweenFilters);
        }
    }
    function filterAll(){
        setTimeout(_filterAll,300);
    }
    function _filterAll(){
        $("[data-testid='fbfeed_story']").map(filter);
    }
});

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址