diff --git a/options.js b/options.js index 3aabc0b..1371539 100644 --- a/options.js +++ b/options.js @@ -48,4 +48,27 @@ function _mk_html(input, clsname){ // Array.from(document.getElementsByClassName('getsets-e2')).map(function(e){e.style.display='none'}) _mk_html(getsets, 'getsets') -_mk_html(funcs, 'funcs') \ No newline at end of file +_mk_html(funcs, 'funcs') + +document.querySelectorAll("input").forEach(function(v){ + chrome.storage.sync.get([v.dataset.key], function (result) { + if (v.type == 'checkbox'){ + v.checked = result[v.dataset.key]; + } + if (v.type == 'text'){ + v.value = result[v.dataset.key] || ''; + } + }) + v.addEventListener("change", function (e) { + if (v.type == 'checkbox'){ + chrome.storage.sync.set({ + [e.target.dataset.key]: e.target.checked + }) + } + if (v.type == 'text'){ + chrome.storage.sync.set({ + [e.target.dataset.key]: e.target.value + }) + } + }) +}) \ No newline at end of file