Chrome Extension (Manifest V3) · Local Ollama Gemma 4 · Built‑In Gemini Nano · Rule Induction
YouTube Nonsense Filter — Local AI Feed Curation & Rule Synthesis
A zero‑dependency Manifest V3 Chrome Extension that strips clickbait, rage‑bait, unwanted channels, Shorts shelves, and low‑effort metadata across the YouTube Home feed, Watch Sidebar ("Up Next"), and Search results—combining instant deterministic rules, batched local Gemma 4 classification, and a 👎/👍 counterexample‑guided rule‑induction loop.
- Manifest V3 · Zero Dependencies
- Local Ollama Gemma 4 · Chrome Gemini Nano · Gemini 2.5 Flash
- 👎 Dislike + 👍 Counterexample Rule Induction
- declarativeNetRequest Localhost Origin Fix
- 16% Opacity Reason Badges + One‑Click Channel Block
Architecture
Deterministic Fast Path First, Batched Local LLM Second, Induced Rules Forever
Running an LLM on every video card on every scroll would saturate local GPU memory. Instead,
content/content.js runs instant deterministic rules first, checks a normalized
500‑entry session cache (title::channel), and batches only novel survivors (up to
8 videos per pass) to service‑worker.js—while synthesizePatternsWithGemma
distills your 👎/👍 feedback into new permanent deterministic rules.
Local AI & Rule Induction
From 👎/👍 Feedback to Deterministic Rules & Zero‑VRAM Idle
1. Counterexample‑Guided Rule Synthesis
Hovering over any video card lets you tag it 👎 Dislike (taggedVideos)
or 👍 Keep (likedVideos). synthesizePatternsWithGemma
gathers newly tagged items (NEW_DELTA_TAG) plus any older tags not yet covered by an
active rule (UNCOVERED_PREVIOUS_TAG), alongside up to 35 👍
counterexamples, and prompts Gemma 4 to induce 2–6 specific keyword,
/regex/i, or channel rules that block the disliked tropes without
matching any 👍 video.
2. Automatic VRAM Unload (keep_alive: 0)
With unloadAfterAnalysis enabled, the extension sends a post‑synthesis
keep_alive: 0 request to Ollama immediately after rule generation finishes — evicting
the model from unified/GPU memory so daily browsing runs at 0 MB VRAM over the newly induced
deterministic rules.
3. Zero‑CORS Localhost Bridge
Ollama rejects requests carrying a chrome‑extension:// Origin header
with HTTP 403 unless the user manually reconfigures OS launch agents. The bundled
declarativeNetRequest rule (rules/ollama‑headers.json) strips the
Origin header on requests to 127.0.0.1 and localhost,
so local Ollama and OpenAI‑compatible servers work out of the box.
4. Four AI Modes + Base Session Cloning
Choose between Local Gemma 4 (Ollama /api/chat with JSON Schema
and think: false, or LM Studio / llama.cpp / MLX via
/v1/chat/completions), Chrome's on‑device Built‑in Gemini Nano
(caching a warm LanguageModel base session and calling .clone() per
batch), or the Google Gemini API (gemini‑2.5‑flash).
Defense Layers
Every Filter Layer & What It Catches
| Filter Layer | What It Evaluates | Default UX Behavior |
|---|---|---|
| Surface & Subscription Controls | Per‑surface toggles for Home Feed, Watch Sidebar ("Up Next"), and Search Results, plus exemptSubscribedChannels and an optional Subscribed‑Only Home Feed mode. |
Exempts subscribed creators or restricts Home exclusively to allowlisted channels. |
| One‑Click Channel & Shorts Filter | Hover ✕ Block Channel button injected on every video card (with instant Undo toast), plus dedicated Shorts shelf & Mix playlist stripping. | Dims to 16% opacity with reason badge or removes (display: none). |
| Keywords, Regex & Learned Rules | Case‑insensitive substrings, slash‑delimited regular expressions (/(exposed|must watch)/i), and Gemma‑induced learnedRules. |
Labels the exact matched pattern on the dimmed card badge; click badge to reveal. |
| Clickbait Typography & Metadata | Excessive ALL CAPS word count (configurable threshold), screaming punctuation (!!! / ???), min/max duration, min view count, and max upload age in years. |
Parses YouTube badge/metadata text in‑place before any AI call is made. |
| Batched AI Smart Filter | Evaluates up to 8 novel titles + channel names + metadata strings per batch against your custom policy prompt + refined learned policy. | Caches verdicts in chrome.storage.session and displays the AI's concise reason on the card badge. |