HistoryCleaner/extension/options.js

26 lines
642 B
JavaScript
Raw Normal View History

2018-09-09 23:02:04 +00:00
const DOM = generateElementsVariable([
"days",
"visitCount",
"mode",
"settings"
]);
function updateDays(e) {
2018-09-09 23:02:04 +00:00
browser.storage.local.set({
days: parseInt(DOM.days.value),
visitCount: parseInt(DOM.visitCount.value),
mode: DOM.mode.value
});
2017-02-07 23:38:33 +00:00
e.preventDefault();
2017-02-07 23:31:13 +00:00
}
2018-09-09 23:02:04 +00:00
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";
2017-02-07 23:31:13 +00:00
}
2018-09-09 23:02:04 +00:00
DOM.settings.addEventListener("input", updateDays);
document.addEventListener("DOMContentLoaded", restoreOptions);