Created
November 3, 2020 16:13
-
-
Save shramee/9a7d56ff76632f35b7b6b85c80ba113f to your computer and use it in GitHub Desktop.
Hide sponsored stuff on FB
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
/* 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; | |
} |
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
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