forked from TheOtherGuy27/uSuperDrag
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.js
45 lines (41 loc) · 1.69 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
chrome.storage.sync.get({
enableTextSearch: true,
searchUrl: 'https://www.google.com/search?q=%s',
enableOpenTabInBg: true,
enableLinkOpen: true,
enableLinkTextSelect: false
}, items => {
for (let element of document.querySelectorAll('[data-translate]')) {
element.textContent = chrome.i18n.getMessage(element.dataset.translate);
}
const enableTextSearch = document.getElementById('enable-text-search');
const searchUrl = document.getElementById('search-url');
const enableOpenTabInBg = document.getElementById('enable-open-tab-in-bg');
const enableLinkOpen = document.getElementById('enable-link-open');
const enableLinkTextSelect = document.getElementById('enable-link-text-select');
const save = document.getElementById('save');
const saveStatus = document.getElementById('save-status');
enableTextSearch.checked = items.enableTextSearch;
searchUrl.value = items.searchUrl;
enableOpenTabInBg.checked = items.enableOpenTabInBg;
enableLinkOpen.checked = items.enableLinkOpen;
enableLinkTextSelect.checked = items.enableLinkTextSelect;
searchUrl.disabled = !enableTextSearch.checked;
enableTextSearch.addEventListener('change', () => {
searchUrl.disabled = !enableTextSearch.checked;
}, false);
save.addEventListener('click', () => {
chrome.storage.sync.set({
enableTextSearch: enableTextSearch.checked,
searchUrl: searchUrl.value,
enableOpenTabInBg: enableOpenTabInBg.checked,
enableLinkOpen: enableLinkOpen.checked,
enableLinkTextSelect: enableLinkTextSelect.checked
}, () => {
saveStatus.style = 'display:inline';
setTimeout(() => {
saveStatus.style = 'display:none';
}, 1000);
});
}, false);
});