-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent.js
31 lines (29 loc) · 952 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
(() => {
chrome.runtime.onMessage.addListener((obj, sender, response) => {
const { msg } = obj;
if (msg === "MSG_CONVERSATIONS") {
const showMoreButton = document.getElementsByClassName("btn btn-small")[0];
if (showMoreButton) {
showMoreButton.click();
}
const nav = document.getElementsByClassName("overflow-y-auto");
nav[0].id = "nav";
let conversations = document.querySelectorAll("#nav .group");
let chats = [];
conversations.forEach(element => {
// Set href to innerText to pinpoint the conversation
element.href = element.innerText
let chat = {
href: element.href,
innerText: element.innerText
}
chats.push(chat)
});
response(chats);
} else if (msg === "MSG_LOAD_CHAT") {
const { title } = obj;
let chat = document.querySelector(`a[href="${title}"]`);
chat.click();
}
});
})();