Skip to content

Instantly share code, notes, and snippets.

@getdave
Last active March 17, 2022 11:38
Show Gist options
  • Save getdave/d428d0855fcff694eaef7ec83289f7af to your computer and use it in GitHub Desktop.
Save getdave/d428d0855fcff694eaef7ec83289f7af to your computer and use it in GitHub Desktop.
Picture In Picture API bookmarketlet - finds the first video element on the page and toggles between Picture In Picture mode - https://developers.google.com/web/updates/2018/10/watch-video-using-picture-in-picture
javascript:(function()%7B(async%20function()%20%7Bconst%20video%20%3D%20document.querySelector('video')%3Bif(!video)%20%7Balert(%22No%20video%20element%20found%20on%20page%22)%3B%7Dif%20(video%20!%3D%3D%20document.pictureInPictureElement)%20%7Bawait%20video.requestPictureInPicture()%3B%7D%20else%20%7Bawait%20document.exitPictureInPicture()%3B%7D%7D())%7D)()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment