Skip to content

Instantly share code, notes, and snippets.

@tsukumijima
Last active January 15, 2020 16:32
Show Gist options
  • Save tsukumijima/1cfd6e63a7cea51c0901391b6a24d0de to your computer and use it in GitHub Desktop.
Save tsukumijima/1cfd6e63a7cea51c0901391b6a24d0de to your computer and use it in GitHub Desktop.
ニコニコの動画をコメント付きでキャプチャして新しいタブに表示するブックマークレット
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