Skip to content

Instantly share code, notes, and snippets.

@kaplas
Forked from mehedihasan/fb.blocker.user.js
Last active January 6, 2016 11:31
Show Gist options
  • Save kaplas/31cf00f605667f7430d9 to your computer and use it in GitHub Desktop.
Save kaplas/31cf00f605667f7430d9 to your computer and use it in GitHub Desktop.
Block/Hide Facebook elements (and do something useful with that time of yours instead!)
// ==UserScript==
// @name Facebook Blocker (by Jouni Kaplas)
// @namespace net.kaplas.fb-blocker
// @include https://*.facebook.com/*
// @include https://facebook.com/*
// @include http://*.facebook.com/*
// @include http://facebook.com/*
// @version 1
// @grant none
// @downloadURL https://gist.github.com/kaplas/31cf00f605667f7430d9/raw/
// @description Block/Hide Facebook elements
// ==/UserScript==
var HIDE_THESE = [
".home #contentArea", // newsfeed
"#pagelet_ego_pane", // suggested pages
"#timeline_info_review_unit" // add this and that to your profile
]
var styleNode = document.createElement('style');
var rules = [];
function addStyleRule(selector, attribute, value) {
rules.push(`${selector} { ${attribute}: ${value} !important }`);
}
// This doesn't hide the actual element, but it's child elements instead.
function hideElementsBySelector(selector) {
var childSelector = `${selector} *`;
addStyleRule(selector, "background-color", "silver");
addStyleRule(childSelector, "visibility", "hidden");
}
HIDE_THESE.forEach(hideElementsBySelector);
styleNode.innerHTML = rules.join("\n");
document.body.appendChild(styleNode);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment