Last active
January 15, 2020 16:32
-
-
Save tsukumijima/1cfd6e63a7cea51c0901391b6a24d0de 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'); | |
var comment = document.querySelectorAll('canvas')[1]; | |
if (comment.width > video.videoWidth){ | |
canvas.width = comment.width; | |
canvas.height = comment.height; | |
} else { | |
canvas.width = video.videoWidth; | |
canvas.height = video.videoHeight; | |
} | |
canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height); | |
canvas.getContext('2d').drawImage(comment, 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