-
Notifications
You must be signed in to change notification settings - Fork 0
/
content_script.js
41 lines (38 loc) · 1.17 KB
/
content_script.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
(function() {
console.log("Hello from teams_chat_download chrome extension by emanuele.paolini@gmail.com");
var content = "";
let chat = document.getElementsByClassName("message-body");
for (let i=0; i<chat.length; ++i) {
const msg = chat[i];
const name = msg.getElementsByClassName("ts-msg-name")[0];
const date = msg.getElementsByClassName("message-datetime")[0];
const text = msg.getElementsByClassName("message-body-content")[0];
var line = "";
if (date) {
line += "["+date.getAttribute("title")+"] ";
}
if (name) {
line += name.innerText.trim();
}
if (text) {
line += ": " + text.innerText.trim();
}
if (line) {
content += line + "\n";
}
}
chrome.runtime.sendMessage({
action: 'download',
message: content
},
function(response) {
if (chrome.runtime.lastError) {
console.log('ERROR: ' + chrome.runtime.lastError.message);
} else {
if (response.status != 'completed') {
console.log('Download failed');
}
}
}
);
})();