Skip to content

Instantly share code, notes, and snippets.

@joshuatz
Last active August 22, 2020 04:35
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 joshuatz/61f72bd9d5432f758743ccfe5e8f4ca9 to your computer and use it in GitHub Desktop.
Save joshuatz/61f72bd9d5432f758743ccfe5e8f4ca9 to your computer and use it in GitHub Desktop.
Video Popper for PiP - Override Disabled PiP Support
let vidPopped = false;
document.querySelectorAll('video').forEach(vid => {
// Override disabling features
vid.removeAttribute('disablepictureinpicture');
vid.disablePictureInPicture = false;
// Only pop right away if video is playing, or on Hulu
if ((!vid.paused || vid.id === 'content-video-player') && !vidPopped) {
if (typeof vid.requestPictureInPicture === 'function') {
vid.requestPictureInPicture()
.then(() => {
vidPopped = true;
})
.catch((err) => {
console.error(`failed to pop video`, vid, err);
});
}
}
});
<a href="javascript:void%20function(){let%20a=!1;document.querySelectorAll(%22video%22).forEach(b=%3E{b.removeAttribute(%22disablepictureinpicture%22),b.disablePictureInPicture=!1,b.paused%26%26%22content-video-player%22!==b.id||a||%22function%22!=typeof%20b.requestPictureInPicture||b.requestPictureInPicture().then(()=%3E{a=!0}).catch(a=%3E{console.error(`failed%20to%20pop%20video`,b,a)})})}();">Vid Popper</a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment