video-snapshot

Capture video snapshot

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         video-snapshot
// @namespace    https://ciffelia.com/
// @version      1.0.1
// @description  Capture video snapshot
// @author       Ciffelia <[email protected]> (https://ciffelia.com/)
// @license      MIT
// @homepage     https://github.com/ciffelia/video-snapshot#readme
// @supportURL   https://github.com/ciffelia/video-snapshot/issues
// @include      *
// @grant        GM_registerMenuCommand
// @run-at       document-idle
// ==/UserScript==

(function () {
  'use strict';

  const createCanvasFromVideo = videoElm => {
    const canvasElm = document.createElement('canvas');
    canvasElm.width = videoElm.videoWidth;
    canvasElm.height = videoElm.videoHeight;

    const ctx = canvasElm.getContext('2d');
    ctx.drawImage(videoElm, 0, 0, videoElm.videoWidth, videoElm.videoHeight);

    return canvasElm
  };

  const downloadBlob = (blob, filename) => {
    const a = document.createElement('a');
    a.style.display = 'none';
    a.href = URL.createObjectURL(blob);
    a.download = filename;

    document.body.appendChild(a);
    a.click();
    document.body.removeChild(a);
  };

  const capture = () => {
    const video = document.querySelector('video');

    const canvas = createCanvasFromVideo(video);

    canvas.toBlob(blob => {
      downloadBlob(blob, 'snapshot.png');
    });
  };

  GM_registerMenuCommand('Capture video snapshot', capture, 'c');

}());