A Firefox extension that prevents YouTube and Vimeo from stopping video playback when the browser is in the background, minimized, or when switching tabs.
This extension ensures that videos on YouTube and Vimeo continue playing even when you switch tabs, minimize the browser, or lock your screen (on mobile). It eliminates the frustration of videos pausing automatically when they lose focus.
- Background Playback: Forces YouTube and Vimeo to continue playing even when the tab is not active.
- Page Visibility API Override: Tricks the websites into thinking the page is always visible (
document.hiddenis alwaysfalse). - Mobile Support: Includes logic for Android and iOS Firefox support with MediaSession API integration.
- Video Recovery: Automatically resumes playback if unexpectedly paused due to browser suspension.
- Lightweight: Minimal performance impact.
The extension uses a lightweight content script to override the Page Visibility API.
- Visibility Override: It intercepts visibility checks from the website, always reporting the page state as
visibleandactive. - Event Blocking: It stops
visibilitychangeevents from propagating to the video player. - MediaSession Integration: On mobile, it ensures the browser's media control center stays active.
- Clone the repository:
git clone https://github.com/LabinatorSolutions/play-youtube-video-in-background.git cd play-youtube-video-in-background - Install dependencies (requires Bun):
bun install
- Build the extension:
The artifact (ZIP file) will be generated in the
bun run build
web-ext-artifacts/directory.
- Open Firefox and navigate to
about:debugging#/runtime/this-firefox. - Click "Load Temporary Add-on...".
- Select the
manifest.jsonfile in the project directory.
- Check if extension is enabled: Navigate to
about:addonsand verify the extension is enabled. - Verify you're on a supported site: The extension only works on YouTube and Vimeo.
- Try reloading the page: Sometimes a page refresh is needed after installing.
- Check browser console: Press
F12and look for any error messages from the extension. - Firefox version: Ensure you're running Firefox 147.0 or later.
- Install the extension.
- Open YouTube or Vimeo.
- Start a video.
- Switch tabs or minimize: The audio/video will keep playing.
To Verify:
- Play a video.
- Switch to another tab or minimize Firefox.
- Desktop: The tab should show the "playing audio" speaker icon.
- Android: You should see the Firefox media control notification in your notification shade, and audio will continue.
Note: This extension focuses purely on background playback. For preventing YouTube's "Are you still watching?" timeout prompts, consider pairing with the YouTube Uninterrupted extension.
- Desktop YouTube: Background playback works natively in most cases; extension primarily helps with mobile.
- Timeout Prompts: This extension does NOT prevent YouTube's "Are you still watching?" prompts. Use YouTube Uninterrupted for that.
- Firefox forks: May not work on Firefox forks that don't support
wrappedJSObject. - Other extensions: Ad blockers or privacy extensions might interfere.
This project uses Bun for dependency management and running scripts.
- Bun (v1.0 or later)
- Firefox (for testing)
| Command | Description |
|---|---|
bun run lint |
Runs ESLint to check for code style and errors. |
bun run lint:fix |
Automatically fixes simple linting errors. |
bun run typecheck |
Runs TypeScript compiler to check types (no emit). |
bun run test |
Runs both linting and type checking validation. |
bun run build |
Packages the extension using web-ext. |
The extension requests permissions for the following domains:
*://*.youtube.com/**://*.youtube-nocookie.com/**://*.vimeo.com/*
These permissions are strictly required to inject the content script that overrides the Page Visibility API on these specific sites. No data is collected or transmitted.
- Issues: Report a Bug
- Source Code: GitHub Repository
This extension is not affiliated with, endorsed by, or officially connected to YouTube, Vimeo, Google, or Mozilla. It is an independent project created for educational purposes and personal use.
The extension respects the terms of service of supported platforms by:
- Not downloading or modifying video content.
- Simply ensuring the browser reports "active" state to the player.
Developed by Labinator.