I built an open-source Chrome Extension to stop my YouTube Shorts addiction (Manifest V3)
Source: Dev.to
The Problem
I’m a high school student hoping to major in Computer Science. A few months ago I noticed a pattern destroying my study sessions:
- Open YouTube to watch a 10‑minute Physics tutorial.
- See a “Shorts” shelf on the homepage.
- Click one…
- Wake up 2 hours later with zero work done.
Existing blockers were either too aggressive (blocking all of YouTube, which I need for tutorials) or paid/closed‑source (which I didn’t trust with my browsing data). I needed a surgical blocker that only removed the Shorts elements.
Solution: FocusTube
I built FocusTube, a Chrome extension (Manifest V3) that removes the slot‑machine‑like Shorts shelves without breaking the rest of YouTube.
View the source code on GitHub
How It Works
YouTube is a Single Page Application (SPA). Clicking a video changes the URL and swaps content via JavaScript instead of reloading the page, so a simple CSS rule isn’t enough—new elements keep re‑appearing.
MutationObserver
The extension uses a MutationObserver to watch the DOM for changes. Whenever YouTube injects a new “Shorts Shelf” or sidebar button, the script detects it and hides it immediately.
const observer = new MutationObserver(() => {
if (isFocusModeOn) manualScan();
});
observer.observe(document.body, { childList: true, subtree: true });
Navigation Events
Because the URL changes without a full reload, the extension also listens for YouTube’s navigation event (yt-navigate-finish) to re‑run its checks each time the user clicks a link.
Modes
Strict Mode
If a direct /shorts/ link is opened, the extension detects the URL pattern and immediately redirects to the homepage using window.location.replace.
Soft Mode
When a softer nudge is preferred, the extension injects a full‑screen HTML overlay that pauses the video and asks: “Do you really need to watch this?”
Privacy First
The extension runs 100 % client‑side. Preferences (Dark Mode, Strict Mode status, etc.) are stored in chrome.storage.local; no data ever leaves the browser.
Release & Installation
- v1.2 has been released and submitted to the Microsoft Edge and Firefox Add‑ons stores (pending review).
- Since it’s open‑source, you can install it today on Chrome, Edge, or Brave via Developer Mode.
GitHub Repo (Download here): https://github.com/malekwael229/FocusTube
Issues / Feedback: Feel free to open an issue if you find a bug!