Skip to content

Instantly share code, notes, and snippets.

@t-wy
Last active July 22, 2022 11:52
Show Gist options
  • Save t-wy/eacb0b79fe31e4fd2628cd5d55f2632d to your computer and use it in GitHub Desktop.
Save t-wy/eacb0b79fe31e4fd2628cd5d55f2632d to your computer and use it in GitHub Desktop.
HTML Video Element Useful Snippets

Below snippets can be used in console or bookmark to perform the desired actions.

javascript: {
let video = document.getElementsByTagName("video")[0];
let canvas = document.createElement("canvas");
canvas.width = video.videoWidth;
canvas.height = video.videoHeight;
canvas.getContext("2d").drawImage(video, 0, 0, canvas.width, canvas.height);
canvas.style.position = "fixed";
canvas.style.left = "0";
canvas.style.top = "0";
canvas.style.zIndex = "99999";
document.body.appendChild(canvas);
canvas.toBlob((blob) => {
navigator.clipboard.write([
new ClipboardItem({ "image/png": blob })
]).then(function() {
document.body.removeChild(canvas);
alert("Done!");
}, function (){
alert("Error!");
});
}, "image/png");
}
// Capture the Current Frame of the Video and copy to Clipboard
javascript: {
let video = document.getElementsByTagName("video")[0];
video.removeAttribute("disablepictureinpicture");
video.requestPictureInPicture();
}
// Open Video in Picture in Picture
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment