Dom image downloader

download dom node as image.

ของเมื่อวันที่ 07-12-2018 ดู เวอร์ชันล่าสุด

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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

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

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

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

// ==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();
        })
    };
})();