---
title: "Filtering the feed: client-side heuristics against AI slop"
description: "Building lightweight browser content filters: DOM mutation observers, pattern matching, layout stability, and zero-network overhead."
date: "2026-11-09"
category: "Building"
featured: false
---

The problem started in my own feed. I was scrolling through a developer news aggregator and noticed that maybe a third of the articles were the same article written slightly differently — the same points, the same structure, different words. Some of them linked to real sources. Some just linked to each other.

DNS blocklists don't help here. The content isn't coming from a known tracking domain. It's on the same CDNs as everything else, served from real-looking URLs. The only thing that's different is the text itself.

[block-ai-slop](https://github.com/pranav256/block-ai-slop) is a browser extension that runs client-side pattern matching against page content and hides results that match. No server, no API calls, no ML models. Just heuristics and DOM manipulation.

## Why it has to run in the browser

A network-level filter sees domains and URLs. It can block `tracking.example.com` but it can't tell the difference between a thoughtful article on `medium.com` and a programmatic summary of a thoughtful article on `medium.com`. Both come from the same origin.

A content script inside the browser sees the rendered text. It can check whether the first paragraph contains "In today's fast-paced digital landscape." It can count the ratio of affiliate links to body paragraphs. It can check the author field against a list of known content farms.

None of that is possible at the network level.

## The broken first approach: scroll events

The obvious implementation is to listen for scroll events and inspect whatever's on screen:

~~~javascript
window.addEventListener('scroll', () => {
  document.querySelectorAll('.feed-item').forEach(card => {
    if (looksLikeSlop(card.textContent)) {
      card.remove();
    }
  });
});
~~~

This causes two problems. First, scroll events fire up to 120 times per second on high-refresh monitors. Querying the full DOM every time is expensive. Second, calling `card.remove()` triggers a synchronous layout recalculation — the browser has to reflow the page every time an element disappears, and doing that inside a scroll handler causes visible stutter.

More importantly, modern feeds don't have all their content in the DOM when you scroll to it. Items get injected asynchronously. A scroll-based approach misses everything that arrives after the initial render.

## MutationObserver and frame-aligned batching

The right tool is `MutationObserver`. It fires a callback whenever nodes are added to the DOM, which is exactly when new feed items appear. No polling, no scroll events.

The trick is batching. The observer fires frequently, and you don't want to process each node synchronously. Instead, collect everything in a `Set` and process it on the next animation frame:

~~~javascript
const queue = new Set();
let scheduled = false;

function processBatch() {
  scheduled = false;
  for (const el of queue) {
    if (!el.isConnected) continue;
    if (matchesPattern(el)) conceal(el);
  }
  queue.clear();
}

const observer = new MutationObserver(mutations => {
  for (const m of mutations) {
    for (const node of m.addedNodes) {
      if (node.nodeType !== Node.ELEMENT_NODE) continue;
      if (node.matches('article, .feed-item, [data-testid="post"]')) {
        queue.add(node);
      } else {
        node.querySelectorAll?.('article, .feed-item')?.forEach(n => queue.add(n));
      }
    }
  }
  if (!scheduled && queue.size > 0) {
    scheduled = true;
    requestAnimationFrame(processBatch);
  }
});

observer.observe(document.body, { childList: true, subtree: true });
~~~

`requestAnimationFrame` aligns processing with the display refresh cycle. Filtering happens once per frame at most, regardless of how fast nodes arrive.

## Don't remove elements, collapse them

The first version removed filtered elements from the DOM entirely. It broke reading.

If you're two-thirds down a feed and three items above you get removed, everything below jumps up by several hundred pixels. You lose your place. This is called Cumulative Layout Shift and it makes the page feel broken even when the filtering is working correctly.

The better approach is to collapse filtered elements to a small placeholder rather than removing them:

~~~css
.filtered {
  display: flex !important;
  align-items: center;
  padding: 6px 12px !important;
  background: #1a1a1a;
  border: 1px solid #333;
  font-size: 11px;
  color: #666;
}

.filtered > * { display: none !important; }

.filtered::before {
  content: "Filtered — click to show";
}
~~~

An 800-pixel article card becomes a 28-pixel bar. The page doesn't jump. If the filter was wrong, you can click to restore the original content.

## What the patterns actually check

Running a language model in a browser extension is impractical — the memory overhead is hundreds of megabytes before you've loaded a single page.

The heuristics that work in practice are simpler:

Synthetic content reuses the same templates. "In today's fast-paced digital landscape" appears at the start of a lot of generated articles. "Delve into" appears in the middle. "By leveraging" shows up before any technical claim. These phrases aren't exclusive to generated content, but their presence is predictive enough to be useful.

Link density matters. An article with eight outbound affiliate links and three paragraphs of body text is almost certainly programmatic content. The ratio is unusual in writing that wasn't optimized for it.

Author metadata is often missing or obviously fake. Sequential username patterns, accounts with no profile image, accounts created in bulk within the same 24-hour window — all of these appear in `meta` tags and sometimes in JSON-LD data embedded in the page.

None of these checks take more than a millisecond per element. The extension adds no measurable latency to page load.

[Browse block-ai-slop on GitHub](https://github.com/pranav256/block-ai-slop).
