-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathoptions.js
More file actions
54 lines (51 loc) · 1.47 KB
/
options.js
File metadata and controls
54 lines (51 loc) · 1.47 KB
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
// Saves options to chrome.storage
function save_options() {
let theme = $('#theme').val();
let colorbg = $('#colorbg').val();
let colorte = $('#colorte').val();
let colortb = $('#colortb').val();
let colortt = $('#colortt').val();
chrome.storage.sync.set({
theme: theme,
colorbg: colorbg,
colorte: colorte,
colortb: colortb,
colortt: colortt,
}, function () {
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
chrome.tabs.update(tabs[0].id, { url: tabs[0].url });
});
});
}
function theme_change(e) {
let theme = $('#theme').val();
if (theme == 'custom') {
$('#colors').show();
} else {
$('#colors').hide();
}
}
function restore_options() {
chrome.storage.sync.get({
theme: 'light',
colorbg: '#FFFFFF',
colorte: '#262626',
colortb: '#FF520E',
colortt: '#FFFFFF',
}, function (items) {
$('#theme').val(items.theme);
$('#colorbg').attr('value', items.colorbg);
$('#colorte').attr('value', items.colorte);
$('#colortb').attr('value', items.colortb);
$('#colortt').attr('value', items.colortt);
$('.color').minicolors({
theme: 'bootstrap'
});
theme_change();
});
}
$(function () {
$('#save').click(save_options);
restore_options();
$('#theme').change(theme_change);
});