Skip to content

Instantly share code, notes, and snippets.

@shramee
Created November 3, 2020 16:13
Show Gist options
  • Save shramee/9a7d56ff76632f35b7b6b85c80ba113f to your computer and use it in GitHub Desktop.
Save shramee/9a7d56ff76632f35b7b6b85c80ba113f to your computer and use it in GitHub Desktop.
Hide sponsored stuff on FB
/* Distracting top tabs */
a[aria-label="Watch"], a[aria-label="Marketplace"], a[aria-label="Groups"], a[aria-label="Gaming"] {
/* Make invisible */
opacity: 0;
}
/* Distracting top tabs on hover (mouseover) */
a[aria-label="Watch"]:hover, a[aria-label="Marketplace"]:hover, a[aria-label="Groups"]:hover, a[aria-label="Gaming"]:hover {
/* Slightly visible on hover */
opacity: .5;
}
/* Ads from right sidebar */
[data-pagelet="RightRail"] > :first-child > :first-child,
/* sm-hide class */
.sm-hide {
/* Make invisible */
opacity: 0;
}
function addClassToSponsoredStuff() {
// Find all sposored labels
document.querySelectorAll( '[aria-label="Sponsored"]' ).forEach( e => {
// Find article, start with parent
let article = e.parentNode;
// Check parents until the article is found
while ( article.role !== 'article' )
article = article.parentNode;
// Add sm-hide class to sponsored articles
article.classList.add( 'sm-hide' );
} )
}
// Do addClassToSponsoredStuff every second (for dynamic content)
setInterval( addClassToSponsoredStuff, 1000 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment