function saveOptions(e) { browser.storage.sync.set({ commentsRemove: document.getElementById("commentsRemoveCheck").checked }); e.preventDefault(); } function restoreOptions() { var gettingItem = browser.storage.sync.get({commentsRemove: false}); gettingItem.then((res) => { document.getElementById("commentsRemoveCheck").checked = res.commentsRemove; }); } document.addEventListener('DOMContentLoaded', restoreOptions); document.querySelector("form").addEventListener("submit", saveOptions);