Skip to content

Instantly share code, notes, and snippets.

@vojtechjurasek
Created March 8, 2019 19:58
Show Gist options
  • Save vojtechjurasek/5e052dcfd475a570ef80c9cc82a296d7 to your computer and use it in GitHub Desktop.
Save vojtechjurasek/5e052dcfd475a570ef80c9cc82a296d7 to your computer and use it in GitHub Desktop.
Minified code of Picture-in-Picture in Google Chrome bookmark. Create bookmark with following code. Don't forget "javascript:" at the beginning.
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