Facebook Filter

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

Mint 2016.01.14.. Lásd a legutóbbi verzió

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         Facebook Filter
// @namespace    thetom.facebook
// @version      1.2
// @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 $stream = $("#stream_pagelet > div:last > div");
	var storyCounter = 0;
    
    String.prototype.contains = function(it) { return this.indexOf(it) != -1; };
	
	function minimize($elem){
		var $title = $elem.find("h5");
		if($title.data("filtered")==="true"){
			return;
		}
		var $story = $elem.find(".userContentWrapper > div:first > div:last");
		storyCounter++;
		$story.hide().attr("id","id"+storyCounter);
		$title.append(" <a id='showStory"+storyCounter+"'>unhide</a><a id='rehideStory"+storyCounter+"' style='display:none'>rehide</a>").data("filtered","true");
		$elem.css({opacity: "0.5"});
		
		var $showLink = $("#showStory"+storyCounter);
		var $rehideLink = $("#rehideStory"+storyCounter);
		$showLink.click(function(){$story.show();$rehideLink.show();$showLink.hide();$elem.css({opacity: "1"});});
		$rehideLink.click(function(){$story.hide();$showLink.show();$rehideLink.hide();$elem.css({opacity: "0.5"});});
	}

    function filter(index,elem){
		if(!$(elem).attr){
			return;
		}
		var $elem = $(elem);
		if($elem.attr("id")){
			if($elem.attr("id").substring(0,10)==="substream_"){
				$elem.find("div[data-ft]").map(filter);
				return;
			}
			if($elem.attr("id").substring(0,11)==="more_pager_"){
				return;
			}
			if($elem.attr("id").substring(0,15)==="newsFeedHeading"){
				return;
			}
			if($elem.attr("id").substring(0,16)!=="hyperfeed_story_"){
				return;
			}
		} else {
			return;
		}
		var title = $elem.find("h5").text();
        if(
			title.contains("liked this.") ||
			title.contains("liked this post ") ||
			title.contains(" likes ") ||
			title.contains(" replied to a comment on this.") ||
			title.contains(" commented on this.") ||
			title.contains(" commented on a post") ||
			title.contains(" is now friends with ") ||
			title.contains(" is interested in an event") ||
			title.contains(" going to an event") ||
			
			title.contains(" se líbí ") ||
			title.contains("liked this post ") ||
			title.contains(" se líbí uživateli ") ||
			title.contains(" tady odpověděl") ||
			title.contains(" okomentovali uživatelé") ||
			title.contains(" okomentovali příspěvek ") ||
			title.contains(" to okomentoval") ||
			title.contains(" is now friends with ") ||
			title.contains(" má zájem o událost") ||
			title.contains(" se zúčastní události")
		){
             minimize($elem);
		}
    }
    function filterAll(){
		setTimeout(_filterAll,500);
	}
    function _filterAll(){
        $stream.children().map(filter);
    }
    
   filterAll();
    $(document).on("scroll",filterAll);
});