-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
42 lines (37 loc) · 1.5 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
37
38
39
40
41
42
const extensionHeader = document.getElementById('extension-header');
const focusBtn = document.getElementById('focus-btn');
const keywordInput = document.getElementById('keyword-input');
const pauseBtn = document.getElementById('pause-btn');
var isActive = 1;
chrome.storage.session.get(['pauseBtn'], function(result) {
const iconPath = result.pauseBtn || "icons/pause-btn.png";
pauseBtn.src = iconPath;
});
chrome.storage.session.get(['keywordInput'], function(result) {
keywordInput.value = result.keywordInput || "";
});
pauseBtn.addEventListener('click', () => {
// alert("pause");
isActive = !isActive;
if(isActive){
pauseBtn.src = "icons/pause-btn.png";
keywordInput.style.borderColor = "green";
keywordInput.style.borderWidth = "4px";
} else {
keywordInput.style.borderColor = "#ccc";
keywordInput.style.borderWidth = "1px";
pauseBtn.src = "icons/play-btn.png";
}
// pauseBtn.src = isActive ? "icons/pause-btn.png" : "icons/play-btn.png";
// alert(isActive);
chrome.runtime.sendMessage({isActive: isActive});
chrome.storage.session.set({pauseBtn: pauseBtn.src});
});
focusBtn.addEventListener('click', () => {
chrome.runtime.sendMessage({ keywordInput: keywordInput.value } , (response) => {
// console.log("sent keywordInput to background.js");
});
keywordInput.style.borderColor = "green";
keywordInput.style.borderWidth = "4px";
chrome.storage.session.set({keywordInput: keywordInput.value});
});