Cleaning Up the LinkedIn Feed with a Tampermonkey Userscript

A free, open-source Tampermonkey userscript that hides the LinkedIn sidebar, ads, suggested posts, and posts from 2nd and 3rd degree strangers on the home feed, while keeping posts from your own network.

I got tired of scrolling past unrelated content on LinkedIn. Between promoted posts, “Recommended for you” blocks, and posts from people I have never met that showed up only because a stranger reacted to them, most of my home feed had nothing to do with my network. So I wrote a small userscript that cleans it up and keeps what I care about.

It is free to use, tweak, or fork: LinkedIn Cleanup on GitHub Gist.

What It Hides

The script only runs on the home feed (linkedin.com/ and linkedin.com/feed/). Profiles, messaging, and search are left alone, and when you navigate away from the feed it restores everything it changed.

On the feed, it hides:

  • The right sidebar, including LinkedIn News and the puzzles widget.
  • Promoted and sponsored posts.
  • Recommendation blocks such as “Recommended for you”, “Add to your feed”, and “People you may know”.
  • Posts whose author is a 2nd or 3rd+ degree connection.
  • Activity posts that appear only because someone “finds this funny”, “finds this curious”, or “follows” someone.
  • Upsell links in the left column, such as “Try Premium Page” and “Advertise on LinkedIn”.
  • The messaging drawer at the bottom of the feed. The “Message” button on profiles still works.

What It Keeps

Hiding everything from outside your network would also remove posts your connections are actively engaging with, which are often the useful ones. So the script keeps a post visible when one of your connections commented on it, replied to it, or reposted it. With the default KEEP_LIKES = true, a post also stays visible when a connection likes, celebrates, supports, loves, or finds it insightful.

Installation

  1. Install the Tampermonkey extension. I tested the script in Chrome.
  2. Open the gist and click Raw on linkedin-cleanup.user.js. Tampermonkey will offer to install it.
  3. Reload LinkedIn.

If nothing changes in Chrome, open Tampermonkey’s details page in chrome://extensions and turn on Allow User Scripts (on older Chrome versions, turn on Developer mode instead). Chrome requires this before any extension can run userscripts.

Configuration

Every behavior is a flag at the top of the script, so you can switch off anything you want to keep:

const HIDE_RIGHT_SIDEBAR   = true;
const HIDE_ACTIVITY_POSTS  = true;  // "X finds this funny", "X follows ..."
const KEEP_LIKES           = true;  // keep posts a connection liked/celebrated/supported
const HIDE_DEGREE_POSTS    = true;  // posts whose author is 2nd / 3rd+
const HIDE_PROMOTED        = true;
const HIDE_RECOMMENDED     = true;  // "Recommended for you", "Add to your feed"
const HIDE_LEFT_LINKS      = true;  // Try Premium Page, Advertise on LinkedIn
const HIDE_MESSAGING       = true;  // feed only
const DRY_RUN              = false; // true = hide nothing, only record what WOULD be hidden

DRY_RUN is useful when you change a rule and want to see what it would hide before it hides anything.

How It Works

A few details took more iterations than I expected.

Collapsing instead of removing. The obvious approach is display: none. That breaks infinite scroll. LinkedIn loads more posts when its lazy-load observers see the end of the list, and an element with display: none has no box for them to see. Hide enough posts that way and the feed simply stops loading. The script instead collapses hidden posts to zero height with visibility: hidden, so they still exist in the layout and scrolling keeps working. It also collapses the outermost wrapper of each post, so no empty divider or spacer is left behind.

Matching on text, not class names. LinkedIn’s class names change often. The script looks for stable visible text instead: the “2nd” or “3rd+” badge next to an author’s name, the word “Promoted”, or a header like “finds this funny”. A cheap regular expression filters out almost every text node first, so the more expensive checks only run on the few that could matter.

Staying fast while you scroll. A MutationObserver queues every node LinkedIn adds as the feed loads. The queue is processed in requestIdleCallback slices of about 6 ms, and all measuring happens before any hiding, so the page does not have to recalculate its layout over and over. Posts that are not laid out yet are retried a moment later.

Private by default. The script includes an optional debug report for when LinkedIn changes its markup and something stops matching. It is off by default, it is stored only in your browser, and it records page structure and counts, never names or post text.

Limitations

LinkedIn changes its markup regularly, so a rule that works today may stop matching later. If something stops being hidden, or something you want is hidden, leave a comment on the gist and I will take a look.


Get the script: gist.github.com/iamgmujtaba. Connect with me on LinkedIn if you build on it.