Vimeo: picture-in-picture button
Adds a floating button that opens the current video in picture-in-picture mode and closes it again.
Code to copy
// Add a floating button that opens the video in picture-in-picture
function addPipButton() {
if (document.getElementById('jz-vmo-pip')) return;
const v = document.querySelector('video');
if (!v) return;
const b = document.createElement('button');
b.id = 'jz-vmo-pip';
b.textContent = 'PiP';
b.style.cssText = 'position:fixed;bottom:14px;right:14px;z-index:99999;background:#00adef;color:#fff;border:0;border-radius:6px;padding:8px 12px;font:13px sans-serif;cursor:pointer;';
b.addEventListener('click', function () {
const vid = document.querySelector('video');
if (vid && document.pictureInPictureEnabled) {
if (document.pictureInPictureElement) { document.exitPictureInPicture(); }
else { vid.requestPictureInPicture().catch(function () {}); }
}
});
document.body.appendChild(b);
}
addPipButton();
const obs = new MutationObserver(addPipButton);
obs.observe(document.documentElement, { childList: true, subtree: true });
How to use this example
- Copy the code with the button above.
- Install JustZix (2 minutes) and open the extension on the target page.
- Add a new rule matching that page.
- Paste the code into the rule's JavaScript panel and save — it runs on every page visit.
Rate this example
No ratings yet — be the first.