A firefox extension to autorefresh the feed every X seconds
at main 1.1 kB view raw
1document.addEventListener('DOMContentLoaded', () => { 2 const intervalSelect = document.getElementById('refreshInterval'); 3 const saveButton = document.getElementById('saveInterval'); 4 5 // Load the saved interval from storage when the popup opens 6 browser.storage.local.get('refreshInterval').then(result => { 7 if (result.refreshInterval) { 8 intervalSelect.value = result.refreshInterval / 1000; // Convert milliseconds to seconds for the dropdown 9 } 10 }); 11 12 saveButton.addEventListener('click', () => { 13 const selectedIntervalSeconds = parseInt(intervalSelect.value); 14 const selectedIntervalMilliseconds = selectedIntervalSeconds * 1000; 15 16 // Save the selected interval to storage 17 browser.storage.local.set({ refreshInterval: selectedIntervalMilliseconds }).then(() => { 18 // Send a message to the background script to update the interval 19 browser.runtime.sendMessage({ action: 'updateInterval', interval: selectedIntervalMilliseconds }); 20 window.close(); // Close the popup after saving 21 }); 22 }); 23});