Skip to content

Instantly share code, notes, and snippets.

@funkyremi
Last active February 25, 2019 19:23
Show Gist options
  • Save funkyremi/97ea27b434686f4a0485b747a59afba7 to your computer and use it in GitHub Desktop.
Save funkyremi/97ea27b434686f4a0485b747a59afba7 to your computer and use it in GitHub Desktop.
Capture picture from videos online
// Paste the following code in your developer console
var canvas = document.createElement('canvas');
var theVideo = document.querySelector('video');
canvas.width = theVideo.videoWidth;
canvas.height = theVideo.videoHeight;
canvas.getContext('2d').drawImage(theVideo, 0, 0, theVideo.videoWidth, theVideo.videoHeight);
var png = canvas.toDataURL('image/png');
var link = document.createElement('a');
link.href = png;
link.setAttribute('download', 'capture.png');
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
// OR
// Drag and drop the following line in your browser Bookmark toolbar
javascript:var canvas=document.createElement('canvas');var theVideo=document.querySelector('video');canvas.width=theVideo.videoWidth;canvas.height=theVideo.videoHeight;canvas.getContext('2d').drawImage(theVideo,0,0,theVideo.videoWidth,theVideo.videoHeight);var png=canvas.toDataURL('image/png');var link=document.createElement('a');link.href=png;link.setAttribute('download','capture.png');document.body.appendChild(link);link.click();document.body.removeChild(link);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment