-
Notifications
You must be signed in to change notification settings - Fork 4
/
options.js
executable file
·37 lines (31 loc) · 1001 Bytes
/
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
window.addEventListener('load', load);
const ls = chrome.storage.local;
const key = 'customWorkbenchBaseUrl';
async function save() {
if (!ls) {
return chrome.notifications.create({
type: 'basic',
title: 'Error',
iconUrl: 'workbench-3-cube-48x48.png',
message: 'Local storage is required.',
priority: 1
});
}
await ls.set({[key]: this.parentNode.baseUrl.value})
document.getElementById('saved').style.display = 'block';
}
function load() {
document.getElementById('saveBtn').onclick=save;
var baseUrlInput = document.getElementById('baseUrl');
if (!ls) {
baseUrlInput.disabled = true;
document.getElementById('saveBtn').disabled = true;
alert('LocalStorage must be enabled for changing options.');
return;
}
chrome.storage.local.get([key]).then((result) => {
if (result[key]) {
baseUrlInput.value = result[key];
}
});
}