Dom image downloader

download dom node as image.

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

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

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         Dom image downloader
// @namespace    http://sharlock.me/
// @version      0.1.1
// @description  download dom node as image.
// @author       74Sharlock
// @match        *
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    let s = document.createElement('script');
    s.src= '//cdn.bootcss.com/html2canvas/0.5.0-beta4/html2canvas.js'
    document.body.appendChild(s);
    window.downloadNode = async function(node, name){
        node = typeof node === 'string' ? document.querySelector(node) : node;
        let canvas = await html2canvas(node);
        canvas.toBlob(function(blob){
            let a = document.createElement('a');
            a.href = URL.createObjectURL(blob);
            a.download = name || 'node.png';
            a.click();
        })
    };
})();