Skip to content

Instantly share code, notes, and snippets.

@fl0aten
Last active November 25, 2022 20:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fl0aten/0aedb602e9a9168621b19ab87e7f1e36 to your computer and use it in GitHub Desktop.
Save fl0aten/0aedb602e9a9168621b19ab87e7f1e36 to your computer and use it in GitHub Desktop.
Picture-In-Picture Bookmark

Picture-In-Picture Bookmark

Description

The following JavaScript code locates the first video element on the page, removes the attributes that may be blocking the PIP feature, and attempts to open the video in picture-in-picture mode.

var v = document.getElementsByTagName("video").item(0);
v.removeAttribute("disablepictureinpicture");
v.requestPictureInPicture();

(The code does not contain any fallbacks. Either it works, or it doesn't.)

How to use?

To use it, you simply need to create a bookmark in your browser and enter the following as the URL:

javascript:var v=document.getElementsByTagName("video").item(0);v.removeAttribute("disablepictureinpicture");v.requestPictureInPicture();

Now start your video, click the bookmark and enjoy your video in PIP.

By the way: This bookmark even works on Disney+!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment