A seamless Picture-in-Picture experience for YouTube and Bilibili
- Table of Contents
- Overview
- Key Features
- Browser Compatibility
- Browser Setup
- Visual Examples
- Technical Implementation
- Project Statistics
- Resources
- Support
An advanced userscript that automatically triggers Picture-in-Picture (PiP) mode for YouTube and Bilibili videos. This script provides a seamless video-watching experience across multiple browsers, enhancing the native PiP functionality with additional features and broader compatibility.
Note: Many browsers now offer native Auto PiP features in beta/experimental mode.
Automatic PiP Functionality
| Feature | Description |
|---|---|
| Smart Activation | Automatically enters PiP mode during active video playback |
| Tab Management | Intelligently handles tab switching with user interaction detection |
| Pause Handling | Prevents PiP activation during video pauses |
| Click Optimization | Enhanced click event handling for better user experience |
| Cross-Browser | Consistent experience across Chrome, Edge, and Brave |
| Error Resilience | Robust error handling with automatic retry mechanisms |
Native Auto PiP Support Status
| Browser | Native Auto PiP | Status | Available In |
|---|---|---|---|
| Chrome | ✅ | Beta | Chrome 137.0.7151.15+ |
| Firefox | ✅ | Experimental | Firefox 130+ |
| Edge | ❓ | Beta | Edge 137+ (Chromium-based) |
| Brave | ❓ | Beta | Brave 1.63+ |
| Safari | ❓ | Not Available | - |
Using Native Auto PiP
-
Enable Auto PiP Feature (Settings)
Settings → Privacy and Security → Site Settings → Additional PermissionsEnable "Automatically enter Picture-in-Picture mode"
-
Configure Chrome Flags Navigate to
chrome://flagsand enable:#auto-picture-in-picture-for-video-playback#video-picture-in-picture-controls-update-2024#media-session-enter-picture-in-picture#document-picture-in-picture-animate-resize
⚠️ Important Note for Chrome 137.0.7151.15+ Users: If you're using Chrome Beta 137.0.7151.15 or above, also enable:
#browser-initiated-automatic-picture-in-pictureWith this flag enabled and native Auto PiP configured, this userscript becomes optional as the browser now handles automatic PiP functionality natively.
Using Native Auto PiP (Experimental)
-
Enable Experimental Auto PiP Feature
Type about:settings#experimental in the address bar -
Check the box for "picture-in-picture auto-open on tab switch"
-
For manual PiP control:
Settings → General → BrowsingEnsure "Enable picture-in-picture video controls (E)" is checked
Zen Browser (Firefox-based)
Zen Browser is based on Firefox and includes similar Auto PiP functionality. The setup process is similar:
- Navigate to
about:settings#experimentalin Zen Browser - Enable the experimental PiP features
- For best results, ensure you're using Zen Browser version 120 or higher
Note: Zen Browser often includes additional performance optimizations for video playback, which can enhance the PiP experience.
Required for userscript installation in all browsers
Advanced Browser APIs
- Utilizes
navigator.mediaSessionAPI for PiP control - Custom action handlers for PiP state management
- Cross-browser compatibility layer
- Intelligent feature detection
- Progressive enhancement approach
- Graceful fallbacks for unsupported browsers
Documentation & References
| Resource | Link |
|---|---|
| Chrome Auto PiP Documentation | Official Docs |
| Firefox Auto PiP (Experimental) | Firefox Blog |
| Picture-in-Picture API Specification | W3C Spec |
| Firefox Picture-in-Picture User Guide | Firefox Support |
If you find this userscript helpful, consider supporting its development:


