-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
33 lines (29 loc) · 1.15 KB
/
popup.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 tabs = await chrome.tabs.query({});
const startRecordElement = document.getElementById("startRecord");
const stopRecordElement = document.getElementById("stopRecord");
startRecordElement.style.display = "block";
stopRecordElement.style.display = "none";
chrome.storage.local.get("state", (data) => {
if (data.state === "recording") {
startRecordElement.style.display = "none";
stopRecordElement.style.display = "block";
}
});
startRecordElement.addEventListener("click", (e) => {
(async () => {
startRecordElement.style.display = "none";
stopRecordElement.style.display = "block";
chrome.storage.local.set({ state: "recording" });
chrome.action.setIcon({ path: 'icons/recording.png' });
const response = await chrome.runtime.sendMessage({ operation: "start" });
})();
});
stopRecordElement.addEventListener("click", (e) => {
(async () => {
startRecordElement.style.display = "block";
stopRecordElement.style.display = "none";
chrome.storage.local.set({ state: "stopped" });
chrome.action.setIcon({ path: 'images/holmes.png' });
const response = await chrome.runtime.sendMessage({ operation: "stop" });
})();
});