-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerator.js
More file actions
27 lines (21 loc) · 768 Bytes
/
generator.js
File metadata and controls
27 lines (21 loc) · 768 Bytes
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
function download(filename, text) {
var element = document.createElement('a');
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
element.setAttribute('download', filename);
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
}
rows = Array.from(document.getElementsByTagName('tr')).filter((e,i) => i%2 === 1);
data = rows.map((e) => {
columns = Array.from(e.querySelectorAll('td'))
return [columns[0], columns[columns.length-1]]
});
names = data.map((e) => e[0].innerText);
scores = data.map((e) => e[1].innerText);
csv = "";
for (let i=0; i< names.length; i++){
csv+=names[i]+","+scores[i]+"\n";
}
download("notas.csv",csv);