-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent.js
39 lines (34 loc) · 1.23 KB
/
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
34
35
36
37
38
39
function playSound() {
const audio = new Audio(browser.runtime.getURL("sound/alert.mp3"));
audio.play().catch(error => {
console.error("Error playing sound:", error);
});
}
function checkForStatus() {
browser.storage.local.get(['soundCustomerReply', 'soundOpen']).then((data) => {
const { soundCustomerReply = true, soundOpen = true } = data;
const rows = document.querySelectorAll('tr');
for (let row of rows) {
const statusCell = row.querySelector('td:nth-child(6)');
if (statusCell) {
const statusText = statusCell.textContent.trim();
if ((soundCustomerReply && statusText === "Customer-Reply") ||
(soundOpen && statusText === "Open")) {
playSound();
observer.disconnect();
break;
}
}
}
});
}
checkForStatus();
const observer = new MutationObserver((mutationsList) => {
for (let mutation of mutationsList) {
if (mutation.type === 'childList' || mutation.type === 'subtree') {
checkForStatus();
break;
}
}
});
observer.observe(document.body, { childList: true, subtree: true });