Created
January 15, 2020 16:34
-
-
Save tsukumijima/8a5120c492dad01d56c110bd05e8f9ca to your computer and use it in GitHub Desktop.
動画サイトの動画をキャプチャして新しいタブに表示するブックマークレット
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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