-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
36 lines (33 loc) · 1.24 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
34
35
36
document.getElementById("startPauseButton").addEventListener("click", () => {
const startPauseButton = document.getElementById("startPauseButton");
if (startPauseButton.classList.contains("paused")) {
startPauseButton.innerHTML = '<i class="fas fa-play"></i> Start';
startPauseButton.style.backgroundColor = "#28a745";
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
chrome.scripting.executeScript({
target: { tabId: tabs[0].id },
function: startProcessing,
});
});
} else {
startPauseButton.innerHTML = '<i class="fas fa-pause"></i> Pause';
startPauseButton.style.backgroundColor = "#dc3545";
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
chrome.scripting.executeScript({
target: { tabId: tabs[0].id },
function: pauseProcessing,
});
});
}
startPauseButton.classList.toggle("paused");
});
document.getElementById("goButton").addEventListener("click", () => {
chrome.runtime.sendMessage({ action: "navigateToGoogle" });
});
function startProcessing() {
window.isProcessingPaused = false;
processUnreadEmails();
}
function pauseProcessing() {
window.isProcessingPaused = true;
}