-
-
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!)
This file contains hidden or 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 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