Last active
August 22, 2020 04:35
-
-
Save joshuatz/61f72bd9d5432f758743ccfe5e8f4ca9 to your computer and use it in GitHub Desktop.
Video Popper for PiP - Override Disabled PiP Support
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}); | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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