Created
January 16, 2025 18:43
-
-
Save wpbean/d0bbb2a6a2e750654572df498caf78fd to your computer and use it in GitHub Desktop.
FaceBook Reels Hide
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
const fbElementsToHide = ['Stories', 'Reels', 'Open reel in Reels Viewer']; | |
const hiddenElements = new Set(); | |
const hideElementsOnScroll = () => { | |
for (const element of fbElementsToHide) { | |
if (!hiddenElements.has(element)) { | |
const targetElement = document.querySelector(`div[aria-label="${element}"]`); | |
if (targetElement) { | |
targetElement.classList.add('wpbean-facebook-hidden'); | |
hiddenElements.add(element); // Mark this element as handled | |
} | |
} | |
} | |
// Remove event listener if all elements are hidden | |
if (hiddenElements.size === fbElementsToHide.length) { | |
window.removeEventListener('scroll', hideElementsOnScroll); | |
} | |
}; | |
// Add the scroll event listener | |
window.addEventListener('scroll', hideElementsOnScroll); | |
// Initial check in case some elements are already in the viewport | |
hideElementsOnScroll(); |
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
.wpbean-facebook-hidden { | |
display: none!important; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment