Facebook Filter

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

目前為 2016-01-14 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Facebook Filter
// @namespace    thetom.facebook
// @version      1.0
// @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
// ==/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>").data("filtered","true");$elem.css({paddingBottom:"5px", opacity: "0.5"});
		$("#showStory"+storyCounter).click(function(){$story.show();});
	}

    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(" is now friends with ") ||
			title.contains(" is interested in an event")
		){
             minimize($elem);
		}
    }
    function filterAll(){
		setTimeout(_filterAll,500);
	}
    function _filterAll(){
        $stream.children().map(filter);
    }
    
   filterAll();
    $(document).on("scroll",filterAll);
});