Created
February 24, 2026 10:34
-
-
Save renedekat/746e8022f2d96252be5f497ffff9f49d to your computer and use it in GitHub Desktop.
Clean up LinkedIN distractions
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
| // === Declutter & auto-expand LinkedIn feed === | |
| // Hide based on selectors | |
| const hideSelectors = [ | |
| '.update-components-image', | |
| '.update-components-celebration', | |
| '.update-components-linkedin-video', | |
| '.update-components-article__image', | |
| '.ivm-view-attr__img-wrapper', | |
| ]; | |
| // Function to hide unwanted elements by selector | |
| function hideBySelector(root = document) { | |
| hideSelectors.forEach(selector => { | |
| root.querySelectorAll(selector).forEach(el => el.style.display = 'none'); | |
| }); | |
| } | |
| // Faster promoted hiding: only check post cards | |
| function hidePromoted(root = document) { | |
| root.querySelectorAll('[data-urn^="urn:li:activity:"]').forEach(card => { | |
| if (card.textContent && card.textContent.toLowerCase().includes('promoted')) { | |
| card.style.display = 'none'; | |
| } | |
| }); | |
| } | |
| // Function to expand "...more" buttons | |
| function expandMore(root = document) { | |
| root.querySelectorAll('.feed-shared-inline-show-more-text__see-more-less-toggle.see-more') | |
| .forEach(btn => btn.click()); | |
| } | |
| // Apply once initially | |
| hideBySelector(); | |
| hidePromoted(); | |
| expandMore(); | |
| // Observer for new content | |
| const observer = new MutationObserver(mutations => { | |
| mutations.forEach(m => { | |
| m.addedNodes.forEach(node => { | |
| if (!(node instanceof HTMLElement)) return; | |
| // Use requestAnimationFrame for efficient batching | |
| requestAnimationFrame(() => { | |
| hideBySelector(node); | |
| hidePromoted(node); | |
| expandMore(node); | |
| }); | |
| }); | |
| }); | |
| }); | |
| // Observe the body for new posts | |
| observer.observe(document.body, { childList: true, subtree: true }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment