Last active
October 3, 2015 17:39
-
-
Save iMerica/ce77d6ab5ccabcb973f1 to your computer and use it in GitHub Desktop.
Facebook Filter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Facebook filter | |
// @namespace iMerica | |
// @description Hides Facebook posts you don't want to see. | |
// @include http://www.facebook.com/* | |
// @include https://www.facebook.com/* | |
// ==/UserScript== | |
// Install: | |
// Step 1: Install TamperMonkey | |
// Step 2: In Chrome, go to chrome://extensions/ | |
// Step 3: Click on TamperMonkey options | |
// Step 4: Go to new user script tab. | |
// Step 5: Paste this script into it and save. | |
// Notes: | |
// To add more keywords to the blacklist, simply add | |
// more elements to the blacklist array at the bottom of | |
// this script. | |
// ToDo: | |
// - Convert this into a crx file that can be used by dragging into chrome. | |
// - Add a GUI | |
// - Make contains() case insensitve. | |
function contains(arr, value) { | |
for (var i = arr.length - 1; i >= 0; i--) { | |
if (value.search(arr[i]) >= 0) { | |
return true; | |
} | |
} | |
return false; | |
} | |
function hidePostsByKeywords(black_list) { | |
var posts = document.getElementsByClassName('userContentWrapper'); | |
for (var i = posts.length - 1; i >= 0; i--) { | |
if (contains(black_list, posts[i].innerText)) { | |
posts[i].style.display = 'none'; | |
} | |
} | |
} | |
window.addEventListener("load", function() { hidePostsByKeywords(); }, false); }, false); | |
window.addEventListener("DOMNodeInserted", function() { hidePostsByKeywords(['Guns', 'Vaccines', 'Trump', 'Facebook Privacy', 'Global Warming']); }, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment