-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoffscreen.js
More file actions
27 lines (24 loc) · 942 Bytes
/
Copy pathoffscreen.js
File metadata and controls
27 lines (24 loc) · 942 Bytes
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
chrome.runtime.onMessage.addListener((msg, sender, sendResponse) => {
if (msg.action === "playSound") {
const audio = new Audio(chrome.runtime.getURL(msg.file));
audio.play();
return false;
}
if (msg.action === "parseHTML") {
const parser = new DOMParser();
const doc = parser.parseFromString(msg.html, "text/html");
const rows = doc.querySelectorAll("tr");
for (const row of rows) {
const uniqueCell = row.querySelector('td[data-th="Unique"] a');
if (uniqueCell && uniqueCell.textContent.trim() === msg.unique) {
const statusCell = row.querySelector('td[data-th="Status"]');
sendResponse({
status: statusCell ? statusCell.textContent.trim() : null
});
return false;
}
}
sendResponse({ status: null });
return false;
}
});