Skip to content

Instantly share code, notes, and snippets.

@ntippie
Last active March 23, 2024 21:24
Show Gist options
  • Select an option

  • Save ntippie/baf0e8d7ea682c3889c954c46fb29614 to your computer and use it in GitHub Desktop.

Select an option

Save ntippie/baf0e8d7ea682c3889c954c46fb29614 to your computer and use it in GitHub Desktop.
Video Picture-in-Picture Bookmarklet w/ Shadow DOM support
javascript:(function(){ function findAllVideosIncludingShadowDOM(startingElement) { let videos = []; function searchForVideos(node) { if (node.tagName === 'VIDEO') videos.push(node); if (node.shadowRoot) searchForVideos(node.shadowRoot); if (node.childNodes.length) node.childNodes.forEach(searchForVideos); } searchForVideos(startingElement); return videos; } var video = findAllVideosIncludingShadowDOM(document)[0]; video.removeAttribute('disablePictureInPicture'); video.requestPictureInPicture(); })();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment