Auto Picture-in-Picture on Tab Change
Auto-enables PiP for playing videos in Chromium browsers on tab switch. Requires an initial click to unlock and exits on return.
#画中画
#视频
#自动播放
Statistics
Total Installs
65
Last 24h
+0
User Rating
-
Description
Versions1
Ratings0
Permissions
自动在切换标签页时启用画中画模式
🎥 Auto Picture-in-Picture on Tab Change
Automatically enters Picture-in-Picture (PiP) mode for playing videos when you switch away from a tab, and exits PiP when you return.
✨ Features
- ✅ Auto-PiP on tab switch – Triggers on both tab visibility change and window blur.
- ✅ Auto-exit on return – Restores the video to the page when you come back.
- ✅ Smart video selection – Picks the best candidate by visible area and playback state; prioritizes playing videos over paused ones.
- ✅ Skips ineligible videos – Ignores hidden, zero-size, paused, ended, or
disablePictureInPicture-flagged videos. - ✅ One-time unlock – A single click or keypress anywhere on the page (e.g. pressing Space to play) unlocks PiP for the entire session. No repeated interaction needed.
- ✅ Lightweight – No dependencies, no permissions, no external requests.
🔧 Installation
- Install a userscript manager:
- Click the Install button.
- Play a video and interact with the page once (click or keypress) — then PiP activates automatically on every tab switch.
📌 Notes
- Chromium limitation: Chromium-based browsers (Chrome, Brave, Edge, Opera) require at least one user interaction (click or keypress) before
requestPictureInPicture()is permitted by the browser engine. This is a hard engine-level restriction — not a script limitation. Firefox does not have this restriction. - The unlock is session-wide and one-time — any normal interaction (clicking play, pressing Space, clicking a link) satisfies it invisibly.
- Only runs in the top-level frame (
window.top) to avoid conflicts on sites that use iframes. - Does nothing on pages with no
<video>elements.
🌐 Browser Support
| Browser | Works | Notes |
|---|---|---|
| Brave | ✅ | One interaction required |
| Chrome | ✅ | One interaction required |
| Edge | ✅ | One interaction required |
| Opera | ✅ | One interaction required |
| Firefox | ✅ | No interaction required (browser policy) |
Contributing & Reporting Issues
- Contribute by forking the GitHub repository and submitting a pull request.
- Report issues here.
Contact
Donate
If you find this script useful, consider supporting its development:
Thank you for your support!
Statistics
Total Installs
65
Last 24h
+0
User Rating
-