123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- 'use strict';
- const {openPrivateWindow} = require('zombie/webbrowser');
- const {console} = require('zombie/zombie');
- console.log('Opening window...');
- openPrivateWindow('about:')
- .then(w => {
- console.log('doing screenshot...');
- w.screenshot().then(data => {
- w.uri = data;
- console.log('screenshot:', data);
- })
- /*
- w.runScript(function () {
- try {
- let left = 0, top = 0, width, height;
- const curX = window.scrollX, curY = window.scrollY;
- scrollTo(0, 0);
- width = window.innerWidth + window.scrollMaxX - window.scrollMinX;
- height = window.innerHeight + window.scrollMaxY - window.scrollMinY;
-
- const canvas = window.document.createElementNS('http://www.w3.org/1999/xhtml', 'canvas');
- const ctx = canvas.getContext('2d');
- const ratio = window.devicePixelRatio;
- canvas.width = width * ratio;
- canvas.height = height * ratio;
- ctx.scale(ratio, ratio);
- ctx.drawWindow(window, left, top, width, height, 'transparent');
-
- const dataURI = canvas.toDataURL('image/png', '');
- scrollTo(curX, curY);
- return dataURI;
- } catch (e) {
- console.error(e, e + '');
- }
- //console.log(typeof ctx.drawWindow);
- //alert(typeof ctx.drawWindow);
- //return typeof ctx.drawWindow;
- })
- .then(dataURI => {
- console.log('screenshot:', dataURI);
- w.close();
- })
- */
- .catch(e => {
- console.log(e, e + '');
- });
- });
- // vim: ts=4 noet ai
|