Skip to content

Instantly share code, notes, and snippets.

@joshuatz
Last active Aug 22, 2020
Embed
What would you like to do?
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