-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptions.js
More file actions
25 lines (21 loc) · 832 Bytes
/
options.js
File metadata and controls
25 lines (21 loc) · 832 Bytes
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
const idleInput = document.getElementById('idle');
const statusDiv = document.getElementById('status');
document.addEventListener('DOMContentLoaded', () => {
chrome.storage.local.get(['settings'], res => {
const settings = res.settings || { idleThresholdSeconds: 60 };
idleInput.value = settings.idleThresholdSeconds;
});
});
function showStatus(message, type = 'success') {
statusDiv.textContent = message;
statusDiv.className = `status ${type} show`;
setTimeout(() => {
statusDiv.classList.remove('show');
}, 3000);
}
document.getElementById('save').addEventListener('click', () => {
const val = Math.max(5, parseInt(idleInput.value || 60, 10));
chrome.storage.local.set({ settings: { idleThresholdSeconds: val } }, () => {
showStatus('✓ Settings saved successfully!', 'success');
});
});