-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
56 lines (49 loc) · 2.12 KB
/
app.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
chrome.runtime.onMessage.addListener(function (request, sender) {
if (request.action == "getSource") {
let today = new Date();
document.getElementById("date").innerHTML = today.toLocaleString();
exp = /(data-sort-key=".*?")/g;
var ul = document.getElementById("list");
document.getElementById("total").innerHTML = request.source.match(exp).length;
request.source.match(exp).forEach(element => {
exp_name = /(?<=").+(?=\s)/g;
var li = document.createElement("li");
li.appendChild(document.createTextNode(element.match(exp_name)));
li.setAttribute("class", "list-group-item");
ul.appendChild(li);
});
}
});
document.addEventListener('DOMContentLoaded', function () {
var btn = document.getElementById('save');
btn.addEventListener('click', function () {
var desc = new Array();
$("#list").find('.list-group-item').each(function () {
var elem = $(this).text().trim();
desc.push(elem);
});
var csvContent = desc.join(",\n");
var pom = document.createElement('a');
var blob = new Blob(["\ufeff" + csvContent], { type: 'text/csv;charset=utf-8;' });
var url = URL.createObjectURL(blob);
pom.href = url;
let today = new Date();
let date = (today.getMonth() + 1) + '월' + today.getDate() + '일' + today.getHours() + '시' + today.getMinutes() + '분';
pom.setAttribute('download', date + '.csv');
pom.click();
});
});
function onWindowLoad() {
var message = document.querySelector('#message');
chrome.tabs.executeScript(null, {
file: "getPagesSource.js"
}, function () {
if (chrome.runtime.lastError) {
document.getElementById("total-text").style.display = "none";
document.getElementById("user-list").style.display = "none";
document.getElementById("save-btn").style.display = "none";
message.innerText = 'Google Meet에서 접속해주세요!!\n' + chrome.runtime.lastError.message;
}
});
}
window.onload = onWindowLoad;