Greasy Fork is available in English.

Facebook Filter

Minimizes all posts your friends didn't post (friend liked, friend commented, friend attends...)

目前為 2016-02-29 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Facebook Filter
// @namespace    thetom.facebook
// @version      1.6.4
// @description  Minimizes all posts your friends didn't post (friend liked, friend commented, friend attends...)
// @author       TheTomCZ <[email protected]>
// @match        https://www.facebook.com/*
// @require      https://code.jquery.com/jquery-2.1.4.min.js
// @grant        none
// @homepage     https://greasyfork.org/en/scripts/16232-facebook-filter
// ==/UserScript==

$(function() {
    'use strict';
	
	var keywords = ["liked this.",
					"liked this post ",
					" likes ",
					" replied to a comment on this.",
					" commented on this.",
					" commented on a post",
					" is now friends with ",
					" is interested in an event",
					" going to an event",
					" others wrote on ",
					"'s Birthday",
					" reacted to this",
					
					" se líbí ",
					"liked this post ",
					" 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"];
	
	prepare();
    filterAll();
    $(document).on("scroll",filterAll);
	
	function prepare(){
		String.prototype.contains = function(it) { return this.indexOf(it) != -1; };
		/*jshint multistr: true */
		$("head").append("<style>.filteredOut .userContentWrapper > div:first-child > div:last-child{\
                              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 .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("fbFiltered");
	}

    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,10)==="substream_"){
			$elem.find("div[data-ft]").map(filter);
			return;
		}
		if($elem.attr("id").substring(0,16)!=="hyperfeed_story_"){
			return;
		}
		var title = $elem.find("h5").text();
        for(var i in keywords){
			if(title.contains(keywords[i])){
			   minimize($elem);
			   break;
		    }
		}
    }
    function filterAll(){
		setTimeout(_filterAll,500);
	}
    function _filterAll(){
        $("#stream_pagelet > div:last > div").children().map(filter);
    }
});