-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpopup.js
More file actions
33 lines (29 loc) · 916 Bytes
/
Copy pathpopup.js
File metadata and controls
33 lines (29 loc) · 916 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
28
29
30
31
32
33
const startBtn = document.getElementById("startBtn");
const statusText = document.getElementById("status");
const spinner = document.getElementById("spinner");
startBtn.addEventListener("click", async () => {
const [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
if (tab) {
updateUI("Initializing...", true);
chrome.runtime.sendMessage({ action: "start_recording", tabId: tab.id });
}
});
chrome.runtime.onMessage.addListener((msg) => {
if (msg.action === "update_status") {
if (msg.text.includes("Done") || msg.text.includes("Error")) {
updateUI(msg.text, false);
} else {
updateUI(msg.text, true);
}
}
});
function updateUI(text, isLoading) {
statusText.innerText = text;
if (isLoading) {
startBtn.disabled = true;
spinner.style.display = "block";
} else {
startBtn.disabled = false;
spinner.style.display = "none";
}
}