-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
36 lines (27 loc) · 1.13 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
var fs = require('fs');
var exec = require('child_process').execSync;
var API_KEY = 'XXXXXXXXXXXX'; // your url2png APIKEY
var PRIVATE_KEY = 'XXXXXXXXXXXX'; // your url2png SECRET
var url2png = require('url2png')(API_KEY, PRIVATE_KEY);
var dest = fs.statSync('/tmp/message.txt').isFile();
if (!dest) fs.writeFileSync('/tmp/message.txt');
var options = {
viewport: '940x580',
thumbnail_max_width : 940,
protocol: 'https',
delay: 10,
unique: Date.now(),
ttl: 60 * 60 * 24 * 2
};
var time = exec('date +%Y-%m-%d_%H-%M');
var image_name = 'wag'; // name your file
var img_file = image_name + '_' + time + '.png';
img_file = img_file.replace(/[\s\?]/gm,'');
var url = 'google.com'; // the url you wish to have screenshotted and emailed to you
var recipient = '[email protected]'; // email to recieve the picture
var subject = "Subject Line"; // Subject line, be careful to escape quotes
var stream = url2png.readURL(url, options).pipe(fs.createWriteStream(img_file));
stream.on('finish', function() {
exec('mutt -a ' + img_file + ' -s "' + subject + '" -- ' + recipient + ' < /tmp/message.txt');
exec('rm '+ img_file);
});