-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.js
27 lines (25 loc) · 873 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
document.addEventListener('DOMContentLoaded', () => {
const prefixInput = document.getElementById('prefix');
const formatSelect = document.getElementById('format');
const saveButton = document.getElementById('save');
// Load the saved prefix and format.
chrome.storage.sync.get(['prefix', 'format'], (data) => {
if (data.prefix) {
prefixInput.value = data.prefix;
}
if (data.format) {
formatSelect.value = data.format;
}
});
// Save the prefix and format when the user clicks "Save".
saveButton.addEventListener('click', () => {
const prefix = prefixInput.value || '';
const format = formatSelect.value || 'text';
chrome.storage.sync.set({
prefix,
format
}, () => {
alert('Settings saved!');
});
});
});