Last active
January 29, 2021 19:27
-
-
Save Arcitec/e9a4020fa6a647b9c532f134e2d75b20 to your computer and use it in GitHub Desktop.
Save as a bookmarklet to have an easy, 1-click button for opening HTML5 videos in PiP mode.
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
javascript:if("pictureInPictureEnabled"in document&&"querySelectorAll"in document){(async function(){const a=document.querySelectorAll("video");if(0===a.length)window.alert("Sorry, no videos on the page.");else if(0<a.length){const b=a[0];try{b===document.pictureInPictureElement?await document.exitPictureInPicture():await b.requestPictureInPicture()}catch(a){console.error(a)}}})()}else"pictureInPictureEnabled"in document?document.pictureInPictureEnabled||window.alert("Picture-in-Picture not available."):window.alert("Picture-in-Picture is disabled."); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment