Build This Life-Changing Chrome Extension: "Focus Mode for YouTube"

Author

Kritim Yantra

Jun 14, 2025

Build This Life-Changing Chrome Extension: "Focus Mode for YouTube"

πŸ”₯ Ever opened YouTube for "just one video" and emerged hours later, wondering where your day went? You're not alone. YouTube's addictive algorithm costs the average user 11,000 hours of their life. Yet no popular extension solves the core problem: intentional viewing.

Introducing "Focus Mode for YouTube"β€”an extension I'm shocked doesn't exist yet. It transforms YouTube from a time-sink into a focused learning tool, and today I'll show you exactly how to build it.


Why This Extension Will Change Lives

❌ The Problem:

  • Endless autoplay sucks you into rabbit holes
  • Distracting recommendations hijack your attention
  • Comments/suggestions trigger emotional engagement

βœ… The Solution:

Focus Mode gives granular control:

  • Pause autoplay after your target video
  • Hide recommendations until you choose to see them
  • Block comments during focused sessions
  • Set time budgets (e.g., "30 mins of cat videos")

Real impact: Students, professionals, and creators report 2-4 hours DAILY productivity gain with similar manual hacks.


Step-by-Step: Building Focus Mode for YouTube

πŸ“ File Structure

focus-mode-extension/  
β”œβ”€β”€ manifest.json  
β”œβ”€β”€ popup.html  
β”œβ”€β”€ popup.js  
β”œβ”€β”€ background.js  
β”œβ”€β”€ content.js  
β”œβ”€β”€ icons/  
└── styles/  
    β”œβ”€β”€ popup.css  
    └── youtube-override.css  

1. Manifest Setup (manifest.json)

{
  "manifest_version": 3,
  "name": "Focus Mode for YouTube",
  "version": "1.0",
  "description": "Take back control of your YouTube time",
  "icons": { ... },
  "permissions": ["storage", "activeTab", "scripting"],
  "host_permissions": ["*://*.youtube.com/*"],
  "background": {
    "service_worker": "background.js"
  },
  "action": {
    "default_popup": "popup.html"
  },
  "content_scripts": [
    {
      "matches": ["*://*.youtube.com/*"],
      "css": ["styles/youtube-override.css"],
      "js": ["content.js"]
    }
  ]
}

2. Content Script - Modify YouTube (content.js)

Core functionality in 15 lines:

// Listen for settings from popup
chrome.storage.sync.get(['hideRecs', 'pauseAutoplay'], (settings) => {
  if (settings.hideRecs) hideRecommendations();
  if (settings.pauseAutoplay) disableAutoplay();
});

function hideRecommendations() {
  // Hide sidebar and end-screen recommendations
  document.querySelector('#secondary').style.display = 'none';
  document.querySelector('#related').style.display = 'none';
}

function disableAutoplay() {
  // Toggle off autoplay switch
  const autoplayToggle = document.querySelector('.ytp-autonav-toggle-button');
  if (autoplayToggle?.ariaChecked === 'true') autoplayToggle.click();
}

3. Popup Control Center (popup.html)

<div class="container">
  <h1>Focus Mode 🎯</h1>
  
  <div class="switch">
    <label>
      <input type="checkbox" id="hideRecs"> 
      Hide recommendations
    </label>
  </div>
  
  <div class="switch">
    <label>
      <input type="checkbox" id="pauseAutoplay"> 
      Pause autoplay
    </label>
  </div>
  
  <div class="time-budget">
    <label>Time budget (minutes):</label>
    <input type="number" id="timeBudget" min="1" value="30">
  </div>
  
  <button id="applyBtn">Apply Settings</button>
</div>

4. CSS Overrides (youtube-override.css)

Remove distracting elements:

/* Hide recommendations */
#secondary, #related, #comments { 
  display: none !important; 
}

/* Simplify player page */
#masthead-container, #below { 
  opacity: 0.3; 
  transition: opacity 0.3s;
}

#masthead-container:hover, #below:hover {
  opacity: 1;
}

5. Time Budget Feature (background.js)

Gentle nudge when time expires:

chrome.alarms.create('timeCheck', { periodInMinutes: 1 });

chrome.alarms.onAlarm.addListener((alarm) => {
  if (alarm.name === 'timeCheck') {
    chrome.storage.sync.get(['timeBudget', 'startTime'], (data) => {
      if (data.startTime) {
        const elapsed = (Date.now() - data.startTime) / 60000;
        if (elapsed >= data.timeBudget) {
          chrome.tabs.query({url: "*://*.youtube.com/*"}, (tabs) => {
            tabs.forEach(tab => {
              chrome.tabs.sendMessage(tab.id, {action: "timeUp"});
            });
          });
        }
      }
    });
  }
});

Why This Is a Million-Dollar Idea

🌟 Unique Value Proposition

  1. Psychological insight:

    • Doesn't block YouTube (which triggers reactance)
    • Uses "friction design" to encourage intentionality
  2. Monetization-ready:

    • Premium features: Focus analytics, schedule blocking
    • Sponsorships from learning platforms (Coursera, Brilliant)
  3. Virality potential:

    • Shareable focus reports ("I saved 7h this week!")
    • Workspaces/teams version

Key Takeaways & Next Steps

βœ… You just built a life-changing tool in under 100 lines of code!
βœ… Core techniques learned:

  • Modify existing websites
  • Sync settings across sessions
  • Create UX-friendly toggles

πŸš€ Enhance it further:

  1. Add Whitelisted Channels exception
  2. Implement Daily Focus Reports
  3. Build a "Deep Work Mode" (full-screen minimal player)

This isn't just another extensionβ€”it's a digital wellbeing revolution. Be the hero who builds it!

Will you ship it? Tag #FocusModeYT when you do! πŸš€

LIVE MENTORSHIP ONLY 5 SPOTS

Laravel Mastery
Coaching Class Program

KritiMyantra

Transform from beginner to Laravel expert with our personalized Coaching Class starting June 21, 2025. Limited enrollment ensures focused attention.

Daily Sessions

1-hour personalized coaching

Real Projects

Build portfolio applications

Best Practices

Industry-standard techniques

Career Support

Interview prep & job guidance

Total Investment
$200
Duration
30 hours
1h/day

Enrollment Closes In

Days
Hours
Minutes
Seconds
Spots Available 5 of 10 remaining
Next cohort starts:
June 21, 2025

Join the Program

Complete your application to secure your spot

Application Submitted!

Thank you for your interest in our Laravel mentorship program. We'll contact you within 24 hours with next steps.

What happens next?

  • Confirmation email with program details
  • WhatsApp message from our team
  • Onboarding call to discuss your goals

Comments

No comments yet. Be the first to comment!

Please log in to post a comment:

Sign in with Google

Related Posts