HistoryCleaner/extension/options.js
2018-09-09 19:02:04 -04:00

25 lines
642 B
JavaScript

const DOM = generateElementsVariable([
"days",
"visitCount",
"mode",
"settings"
]);
function updateDays(e) {
browser.storage.local.set({
days: parseInt(DOM.days.value),
visitCount: parseInt(DOM.visitCount.value),
mode: DOM.mode.value
});
e.preventDefault();
}
async function restoreOptions() {
const res = await browser.storage.local.get();
DOM.days.value = res.days || 0;
DOM.visitCount.value = res.visitCount || 0;
DOM.mode.value = res.mode || "days";
}
DOM.settings.addEventListener("input", updateDays);
document.addEventListener("DOMContentLoaded", restoreOptions);