-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.js
118 lines (94 loc) · 3.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
var powerSwitch = document.getElementById("powerSwitch");
var themeSelect = document.getElementById("themeSelect");
var careerSelect = document.getElementById("careerSelect");
var gameMinSelect = document.getElementById("gameMinSelect");
var splitsSelect = document.getElementById("splitsSelect");
var efgPctSelect = document.getElementById("efgPctSelect");
var tsPctSelect = document.getElementById("tsPctSelect");
window.addEventListener("load", findAndSetVersion);
function findAndSetVersion() {
document.getElementById("versionText").textContent = chrome.runtime.getManifest().version;
}
window.addEventListener("load", calibrateSettings);
function calibrateSettings() {
chrome.storage.local.get(["powerOn", "darkMode", "careerOn", "gameMinOn", "splitsOn", "efgPctOn", "tsPctOn"], (result) => {
powerSwitch.checked = result.powerOn;
power(powerSwitch);
themeSelect.checked = result.darkMode;
switchTheme(themeSelect);
careerSelect.checked = result.careerOn;
switchCareer(careerSelect);
gameMinSelect.checked = result.gameMinOn;
switchGameMin(gameMinSelect);
splitsSelect.checked = result.splitsOn;
switchShootingSplits(splitsSelect);
efgPctSelect.checked = result.efgPctOn;
switchEfgPct(efgPctSelect);
tsPctSelect.checked = result.tsPctOn;
switchTsPct(tsPctSelect);
})
}
powerSwitch.addEventListener("click", () => { power(powerSwitch) });
function power(powerSwitch) {
if (powerSwitch.checked) {
document.getElementById("titleLink").style.color = "#ED174C";
chrome.storage.local.set({ powerOn: true });
} else {
document.getElementById("titleLink").style.color = "#C4CED4";
chrome.storage.local.set({ powerOn: false });
}
}
themeSelect.addEventListener("click", () => { switchTheme(themeSelect) });
function switchTheme(themeSelect) {
if (themeSelect.checked) {
document.body.style.backgroundColor = "#202020";
document.getElementById("versionText").style.color = "#C4CED4";
document.getElementById("optionsTable").style.color = "#FFFFFF";
chrome.storage.local.set({ darkMode: true });
} else {
document.body.style.backgroundColor = "#FFFFFF";
document.getElementById("versionText").style.color = "#002B5C";
document.getElementById("optionsTable").style.color = "#000000";
chrome.storage.local.set({ darkMode: false });
}
}
careerSelect.addEventListener("click", () => { switchCareer(careerSelect) });
function switchCareer(careerSelect) {
if (careerSelect.checked) {
chrome.storage.local.set({ careerOn: true });
} else {
chrome.storage.local.set({ careerOn: false });
}
}
gameMinSelect.addEventListener("click", () => { switchGameMin(gameMinSelect) });
function switchGameMin(gameMinSelect) {
if (gameMinSelect.checked) {
chrome.storage.local.set({ gameMinOn: true });
} else {
chrome.storage.local.set({ gameMinOn: false });
}
}
splitsSelect.addEventListener("click", () => { switchShootingSplits(splitsSelect) });
function switchShootingSplits(splitsSelect) {
if (splitsSelect.checked) {
chrome.storage.local.set({ splitsOn: true });
} else {
chrome.storage.local.set({ splitsOn: false });
}
}
efgPctSelect.addEventListener("click", () => { switchEfgPct(efgPctSelect) });
function switchEfgPct(efgPctSelect) {
if (efgPctSelect.checked) {
chrome.storage.local.set({ efgPctOn: true });
} else {
chrome.storage.local.set({ efgPctOn: false });
}
}
tsPctSelect.addEventListener("click", () => { switchTsPct(tsPctSelect) });
function switchTsPct(tsPctSelect) {
if (tsPctSelect.checked) {
chrome.storage.local.set({ tsPctOn: true });
} else {
chrome.storage.local.set({ tsPctOn: false });
}
}