Skip to content

Instantly share code, notes, and snippets.

@tsukumijima
Created January 15, 2020 16:34
Show Gist options
  • Save tsukumijima/8a5120c492dad01d56c110bd05e8f9ca to your computer and use it in GitHub Desktop.
Save tsukumijima/8a5120c492dad01d56c110bd05e8f9ca to your computer and use it in GitHub Desktop.
動画サイトの動画をキャプチャして新しいタブに表示するブックマークレット
javascript: (() => {
const video = document.querySelector('video');
if (video) {
var canvas = document.createElement('canvas');
canvas.width = video.videoWidth;
canvas.height = video.videoHeight;
canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height);
canvas.toBlob(function(blob){
image = URL.createObjectURL(blob);
html = window.open();
html.document.write(
`<!Doctype html>
<html>
<head>
<title>Capture Image</title>
</head>
<body style="margin: 0px; background: #000000;">
<img style="display:block; margin: 0px auto; height: 100vh;" src="` + image + `">
</body>
</html>`);
html.window.stop();
}, 'image/png', 1);
} else {
alert('動画が見つかりません。');
 }
})();
void 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment