HTML5 Video Frame Screenshot

Adds ability to take a screenshot from the current frame of a HTML5 video element and be saved to a file named "video_frame.jpg" or "video_frame.png" (image format is configurable). This script is intended to be used as a bookmarklet using this URL: javascript:hvfs_ujs()

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         HTML5 Video Frame Screenshot
// @namespace    https://greasyfork.org/en/users/85671-jcunews
// @version      1.0.5
// @license      GNU AGPLv3
// @description  Adds ability to take a screenshot from the current frame of a HTML5 video element and be saved to a file named "video_frame.jpg" or "video_frame.png" (image format is configurable). This script is intended to be used as a bookmarklet using this URL: javascript:hvfs_ujs()
// @author       jcunews
// @match        *://*/*
// @grant        none
// ==/UserScript==

(function() {

  //=== CONFIGURATION BEGIN ===
  var imageFormat = "jpeg"; //can be one of these: jpeg, png
  //=== CONFIGURATION END ===

  window.hvfs_ujs = function(ele, cv) {
    if (ele = document.querySelector("video")) {
      cv = document.createElement("CANVAS");
      if (cv.width = ele.videoWidth) {
        cv.height = ele.videoHeight;
        cv.getContext("2d").drawImage(ele, 0, 0);
        ele = document.createElement("A");
        ele.href = cv.toDataURL("image/" + imageFormat);
        ele.download = "video_frame." + (imageFormat === "jpeg" ? "jpg" : imageFormat);
        ele.style.visibility = "hidden";
        document.body.appendChild(ele).click();
        ele.remove();
        return;
      } else {
        alert("The HTML5 video media has not been loaded yet.");
      }
    } else {
      alert("There is no HTML5 video on this page.");
    }
  };

})();