pip-anywhere

PiP Anywhere

Picture-in-Picture for any video on any site, including YouTube. The video moves into a real OS window that floats above other applications — not an in-page miniplayer.

Source: https://github.com/starboy-3/pip-anywhere · MIT · Privacy policy

Install

  1. Open chrome://extensions
  2. Turn on Developer mode (top right)
  3. Load unpacked → select this folder

Works in Chrome, Edge, Brave, Yandex, Opera — anything Chromium 116+.

Use

Action How
Pop the video out hover the video → click Pop out
Same, no mouse Alt + P
Pop the whole player out (site controls included) Alt + Shift + P, or Shift-click the button
Same, from the toolbar click the extension icon
Same, from the page right-click → Picture-in-Picture

Hotkeys are rebindable and the on-video button can be turned off, both in the options.

The on-video button is the path that always works. A click inside the page carries the user activation requestPictureInPicture() demands; a toolbar click does not, which is why that route needs the fallback described below.

What it handles

Two PiP modes

Standard (Alt+P) — Chrome draws a floating window containing the video frames. The <video> never leaves the page; site controls do not come along.

Document PiP (Alt+Shift+P) — the site’s real player element is moved into a second document, so its own controls, captions and overlays keep working. The element is put back exactly where it was when the window closes.

Toolbar button vs hotkey

requestPictureInPicture() requires user activation, and Chrome does not forward activation from a toolbar click into an injected script. So the toolbar button and context menu cannot enter PiP directly.

Rather than failing, they arm a one-shot listener: click anywhere in the page and PiP opens. The hotkey has no such step because the keypress happens in the page and carries activation on its own.

This is also why the hotkeys are handled by the content script rather than declared in the manifest’s commands block. A browser-level shortcut is intercepted before the page sees the key, so it would arrive without activation and force the same click-to-confirm step. The trade-off is that the shortcuts do not appear on chrome://extensions/shortcuts; they are rebound in the extension’s own options instead.

Auto pop-out

The “Auto pop out” option tags playing videos with autoPictureInPicture, which is the only gesture-free path Chrome offers. Chrome still gates the behaviour behind a flag:

chrome://flags/#auto-picture-in-picture-for-video-playback   → Enabled

Related, also useful:

chrome://flags/#auto-picture-in-picture-on-window-occluded   → Enabled

Without those flags Chrome only auto-PiPs sites that request the permission themselves (Meet, Zoom). With them, this extension’s tagging makes ordinary videos behave the same way Yandex Browser does out of the box.

macOS: fullscreen apps

The floating window will not appear over an app in macOS fullscreen. Fullscreen apps get their own Space and a browser-drawn window does not follow them there. This is a platform limitation, identical in Chrome and Yandex — only Safari escapes it, because its PiP window is created by the system rather than the browser.

Workaround: maximise the other app instead of fullscreening it — Option + green button.

Files

manifest.json      MV3 manifest, content script in all frames
src/content.js     video discovery, both PiP modes, hotkeys, gesture fallback
src/background.js  toolbar / context menu routing, frame probing
src/options.html   settings UI
src/options.js     settings storage and hotkey capture

build.sh           validates and packages dist/pip-anywhere-<version>.zip
PRIVACY.md         privacy policy (nothing is collected)
store/             Web Store listing copy and artwork
tools/             CDP harness, capture and artwork scripts — not shipped

Packaging

./build.sh

Zips manifest.json, src/ and icons/ only, after checking that every path the manifest names exists, that the icons are the size they claim, that no chrome.* API is used without its permission, and that no networking or eval call contradicts PRIVACY.md. Everything the store form needs is in store/listing.md; node tools/check-listing.mjs verifies the length-limited fields.

Store artwork is regenerated, not mocked up:

tools/make-demo-video.sh     # demo clip for the sample page
node tools/capture.mjs       # real page + real PiP window + options, via CDP
node tools/shots.mjs         # composes the three 1280x800 screenshots

Permissions

Nothing is collected or sent anywhere; there is no network code in the extension.