-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwriteScript.js
38 lines (34 loc) · 1.06 KB
/
writeScript.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
37
38
// post-run: execute iMacros for Internet Explorer on Windows
var fs = require('fs');
var Typeform = require('typeform-node-api');
const credentials = require('./credentials.json')
var typeform_api = new Typeform(credentials.key);
let formIds = [];
// get form ids from api
typeform_api.getForms(function (data) {
data.forEach(form => {
formIds.push(form.id);
});
writeScript();
});
function writeScript() {
var stream = fs.createWriteStream("iMacrosScript.txt");
stream.once('open', function (fd) {
let before = `
SET !ERRORIGNORE YES
VERSION BUILD=1003 RECORDER=CR\n `;
stream.write(before);
formIds.forEach(id => {
let code = `
URL GOTO = https://admin.typeform.com/form/${id}/results#responses
TAG POS=7 TYPE=DIV ATTR=TXT:Download<SP>all<SP>responses
TAG POS=1 TYPE=DIV ATTR=TXT:XLSX<SP>file
TAG POS=3 TYPE=DIV ATTR=TXT:Download
ONDOWNLOAD FOLDER = C:\\Users\\UT17\\Downloads\\responses FILE=* WAIT=YES\n`
stream.write(code);
});
// let after = 'SET !ERRORIGNORE NO';
// stream.write(after);
stream.end();
});
}