This repository has been archived by the owner on Dec 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
options.js
56 lines (49 loc) · 2.01 KB
/
options.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
document.addEventListener('DOMContentLoaded', function () {
const enableStickersOption = document.getElementById('enableStickers');
const profitColorOption = document.getElementById('profitColor');
const lossColorOption = document.getElementById('lossColor');
const neutralColorOption = document.getElementById('neutralColor');
const sihTokenOption = document.getElementById('sihToken');
const resetButton = document.getElementById('reset');
chrome.storage.local.get(['enableStickers', 'profitColor', 'lossColor', 'neutralColor', 'sihToken'], function (result) {
enableStickersOption.checked = result.enableFeature || false;
profitColorOption.value = result.profitColor || '#00FF00';
lossColorOption.value = result.lossColor || '#FF0000';
neutralColorOption.value = result.neutralColor || '#FFA500';
sihTokenOption.value = result.sihToken || '';
});
enableStickersOption.addEventListener('change', function () {
const enableFeature = checkboxOptionOption.checked;
chrome.storage.local.set({ enableFeature });
});
profitColorOption.addEventListener('change', function () {
const profitColor = profitColorOption.value;
chrome.storage.local.set({ profitColor });
});
lossColorOption.addEventListener('change', function () {
const lossColor = lossColorOption.value;
chrome.storage.local.set({ lossColor });
});
neutralColorOption.addEventListener('change', function () {
const neutralColor = neutralColorOption.value;
chrome.storage.local.set({ neutralColor });
});
sihTokenOption.addEventListener('change', function () {
const sihToken = sihTokenOption.value;
chrome.storage.local.set({ sihToken });
});
resetButton.addEventListener('click', function () {
chrome.storage.local.set({
enableStickers: false,
profitColor: '#00FF00',
lossColor: '#FF0000',
neutralColor: '#FFA500',
sihToken: ''
});
enableStickersOption.checked = false;
profitColorOption.value = '#00FF00';
lossColorOption.value = '#FF0000';
neutralColorOption.value = '#FFA500';
sihTokenOption.value = '';
});
});