-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.js
48 lines (42 loc) · 1.62 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
43
44
45
46
47
48
if (document.querySelector(".body")) {
const button = document.querySelector(".button");
const circle = document.querySelector(".circle");
// const html = document.querySelector("html");
// console.log(html.style.filter);
// Load isClicked from storage
chrome.storage.sync.get(["isClicked"], function (result) {
let isClicked = result.isClicked;
if (isClicked) {
circle.style.animation = "moveCircleRight forwards";
button.style.animation = "transformToBlue forwards";
} else {
circle.style.animation = "moveCircleLeft forwards";
button.style.animation = "transformToYellow forwards";
}
button.addEventListener("click", () => {
if (!isClicked) {
// Save isClicked to storage
chrome.storage.sync.set({ isClicked: true }, function () {
console.log("Value is set to " + true);
circle.style.animation = "moveCircleRight 1s forwards";
button.style.animation = "transformToBlue 1s forwards";
isClicked = true;
});
chrome.tabs.executeScript({
file: "appOn.js",
});
} else {
// Save isClicked to storage
chrome.storage.sync.set({ isClicked: false }, function () {
console.log("Value is set to " + false);
circle.style.animation = "moveCircleLeft 1s forwards";
button.style.animation = "transformToYellow 1s forwards";
isClicked = false;
});
chrome.tabs.executeScript({
file: "appOff.js",
});
}
});
});
}