-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent.js
33 lines (29 loc) · 890 Bytes
/
content.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
(() => {
const findChats = () => {
const textBases = document.getElementsByClassName('text-base')
const chats = []
for (let i = 0; i < textBases.length; i++) {
const textBase = textBases[i];
const chat = textBase.children[1].children[0].innerHTML;
chats.push(chat);
}
return chats
}
chrome.runtime.onMessage.addListener((obj, sender, response) => {
const { type, value } = obj;
if (type === "LOAD") {
console.log("LOAD");
} else if (type === "CONVERT-MD") {
const chats = findChats();
response(chats);
} else if (type === "CONVERT-HTML") {
const chats = findChats();
const html = chats.join('<br/><br/>');
response(html);
} else if (type === "CONVERT-JSON") {
const chats = findChats();
const json = JSON.stringify(chats);
response(json);
}
});
})();