function persistOptions() { var globals = {}; //global addon options globals = { width: document.querySelector('#indicator-width').value, orientation: document.querySelector('#indicator-orientation').value }; return browser.storage.local.set({ globals: globals }); } document.addEventListener('DOMContentLoaded', () => { loadOptions().then((options) => { document.querySelector('#indicator-width').value = options.globals.width; document.querySelector('#indicator-orientation').value = options.globals.orientation; }); }); var list = document.querySelectorAll('select,input'); for (var i = 0; i < list.length; i++) { list[i].addEventListener('change', (ev) => { persistOptions(); }); }