forked from inquid/github-stories
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptions.js
More file actions
22 lines (19 loc) · 963 Bytes
/
Copy pathoptions.js
File metadata and controls
22 lines (19 loc) · 963 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const DEFAULT_CHAT_URL = 'https://github-chat.com/';
const STORAGE_KEY = 'githubChatUrl';
const input = document.getElementById('chat-url');
const status = document.getElementById('status');
chrome.storage.sync.get({ [STORAGE_KEY]: DEFAULT_CHAT_URL }, (items) => {
input.value = items[STORAGE_KEY];
});
document.getElementById('save').addEventListener('click', () => {
if (!input.checkValidity()) {
input.reportValidity();
return;
}
chrome.storage.sync.set({ [STORAGE_KEY]: input.value }, () => {
status.textContent = 'Saved.';
setTimeout(() => {
status.textContent = '';
}, 1600);
});
});