Skip to content

Instantly share code, notes, and snippets.

@tthew
Last active December 24, 2017 12:43
Show Gist options
  • Save tthew/2c80ff69da0165284953d9d75d7b2195 to your computer and use it in GitHub Desktop.
Save tthew/2c80ff69da0165284953d9d75d7b2195 to your computer and use it in GitHub Desktop.
Free yourself from the Facebook feed.
// ==UserScript==
// @name Freed
// @description Free yourself from the Facebook feed.
// @version 1
// @include https://www.facebook.com/*
// @grant GM_addStyle
// ==/UserScript==
GM_addStyle(`
div[role=feed] {
display: none;
}
`);
const freeMe = () => {
const feed = document.querySelector('div[role=feed]');
if (feed) {
feed.parentNode.removeChild(feed);
}
};
// Watch #content_container for changes and call freeMe on mutations
const target = document.querySelector('#content_container');
if (target) {
const observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
freeMe();
});
});
const config = { attributes: true, childList: true, characterData: true };
observer.observe(target, config);
}
window.onpopstate = freeMe;
freeMe();
console.log('Your feed is being hidden by the Freed UserScript ₍˄·͈༝·͈˄₎◞');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment