Skip to content

Instantly share code, notes, and snippets.

@mimonelu
Last active December 9, 2018 14:13
Show Gist options
  • Select an option

  • Save mimonelu/741180edc7a635d55b6ce73328c2fb60 to your computer and use it in GitHub Desktop.

Select an option

Save mimonelu/741180edc7a635d55b6ce73328c2fb60 to your computer and use it in GitHub Desktop.
📹 動画(videoタグ)のスナップショットをダウンロードするブックマークレット
javascript: (function () { var target = document.querySelector("video"); if (target) { var canvas = document.createElement("canvas"); canvas.width = target.clientWidth; canvas.height = target.clientHeight; var context = canvas.getContext("2d"); context.drawImage(target, 0, 0, canvas.width, canvas.height); var image = new Image(); image.src = canvas.toDataURL("image/png"); var a = document.createElement("a"); a.download = location.host + "_" + (new Date()).toISOString() + ".png"; a.target = "_blank"; a.href = image.src; a.click(); } else { alert("There is no video tag."); } })(); void 0;
@mimonelu
Copy link
Author

mimonelu commented Feb 16, 2018

注意事項

  • Chrome でしか動かないはず
  • video タグがないとダメ
  • video タグがいっぱいある場合は最初のタグだけ対象にする
  • CORS 由来のエラーで動作しない場合がある

動作確認サービス

✅ ニコニコ動画( HTML5 版のみ)
✅ ニコニコ生放送( HTML5 版のみ)
✅ Twitch
✅ YouTube
❌ Vimeo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment