YouTube-Pause-on-Tab-Switch

πŸŽ₯ YouTube Pause on Tab Switch

License: MIT Chrome Web Store Privacy Policy

A lightweight, seamless Google Chrome extension that automatically manages YouTube playback based on your tab focus. It automatically pauses active YouTube videos the moment you switch to another tab or minimize your browser, and instantly resumes playback when you switch back.

Never miss a moment of your favorite podcasts, tutorials, or music videos while multitasking!

πŸ”’ Read Our Privacy Policy


✨ Features


πŸ“¦ Installation

From Chrome Web Store

You can install the extension directly from the official store listing:

πŸ‘‰ YouTube Pause on Tab Switch on Chrome Web Store

Load from Source (Developer Mode)

To run this extension locally or test custom modifications:

  1. Clone the Repository:
    git clone https://github.com/fineanmol/YouTube-Pause-on-Tab-Switch.git
    cd YouTube-Pause-on-Tab-Switch
    
  2. Open Extensions Page: Open Google Chrome and navigate to chrome://extensions/ by typing it in the address bar.

  3. Enable Developer Mode: Toggle the Developer mode switch in the top-right corner of the page.

  4. Load the Extension:
    • Click the Load unpacked button in the top-left corner.
    • Select the Youtube-Pause-Extension directory containing the manifest.json file.
  5. Start Watching: Open a YouTube video, start playing it, and switch tabs to see the extension in action!

πŸ› οΈ How It Works

The extension is powered by three main components:

  1. Background Service Worker (background.js):
    • Monitors tab activation, load states, and window focus changes.
    • Saves playback states to track whether a video was playing before loss of focus.
    • Communicates with content scripts via Chrome messaging.
  2. Content Script Injection (content.js):
    • Runs in the context of YouTube pages to inspect, play, or pause the video elements.
    • Responds to query messages about playback states safely.
  3. Popup Interface (popup.html / popup.js):
    • Provides a settings UI that persists preferences in chrome.storage.local.

πŸ“‚ Project Structure

YouTube-Pause-Extension/
β”œβ”€β”€ manifest.json       # Metadata, permissions, and popup settings
β”œβ”€β”€ background.js       # Background service worker coordinating state and logic
β”œβ”€β”€ content.js          # Injected content script interfacing with YouTube player
β”œβ”€β”€ popup.html          # Beautiful HTML settings panel UI
β”œβ”€β”€ popup.js            # JavaScript backing the settings panel
β”œβ”€β”€ LICENSE             # Open-source MIT License
β”œβ”€β”€ README.md           # Documentation and overview
└── images/             # Extension logo icons
    β”œβ”€β”€ icon16.png
    β”œβ”€β”€ icon48.png
    └── icon128.png

πŸ”’ Privacy & Security

This extension is built with a strict privacy-first architecture:


🀝 Contributing

Contributions make the open-source community an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project.
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature).
  3. Commit your Changes (git commit -m 'Add some AmazingFeature').
  4. Push to the Branch (git push origin feature/AmazingFeature).
  5. Open a Pull Request.

πŸ“„ License

Distributed under the MIT License. See LICENSE for more information.