| 64 | // ============================================================================ |
| 65 | |
| 66 | function setupRangeInput(inputId, valueId, savedId, storageKey, defaultValue, transform = (v) => v) { |
| 67 | const input = document.getElementById(inputId); |
| 68 | const value = document.getElementById(valueId); |
| 69 | |
| 70 | if (!input || !value) return; |
| 71 | |
| 72 | // Load saved value |
| 73 | chrome.storage.sync.get(storageKey, (data) => { |
| 74 | const val = data[storageKey] !== undefined ? data[storageKey] : defaultValue; |
| 75 | input.value = val; |
| 76 | value.textContent = val; |
| 77 | }); |
| 78 | |
| 79 | // Save on change |
| 80 | input.addEventListener('input', (e) => { |
| 81 | const val = transform(e.target.value); |
| 82 | value.textContent = e.target.value; |
| 83 | saveOption(storageKey, val, savedId); |
| 84 | }); |
| 85 | } |
| 86 | |
| 87 | // ============================================================================ |
| 88 | // CHECKBOXES |