var default_preferences = {"pbkdf2_level": 1000, "account_url": "https://gpass-demo.soutade.fr/demo", "crypto_v1_compatible": true}; function save() { var account_url = document.getElementById('account_url').value; var pbkdf2 = document.getElementById('pbkdf2').value; var crypto_v1_compatible = document.getElementById('crypto_v1_compatible').checked; chrome.storage.local.set({ 'account_url': account_url, 'pbkdf2': pbkdf2, 'crypto_v1_compatible': crypto_v1_compatible, }, function() { alert('Saved'); }); } chrome.storage.local.get(null, function(prefs) { if (!prefs.hasOwnProperty("account_url")) account_url = default_preferences['account_url']; else account_url = prefs['account_url']; if (!prefs.hasOwnProperty("pbkdf2_level")) pbkdf2 = default_preferences['pbkdf2_level']; else pbkdf2 = prefs['pbkdf2_level']; if (!prefs.hasOwnProperty("crypto_v1_compatible")) crypto_v1_compatible = default_preferences['crypto_v1_compatible']; else crypto_v1_compatible = prefs['crypto_v1_compatible']; document.getElementById('account_url').value = account_url; document.getElementById('pbkdf2').value = pbkdf2; document.getElementById('crypto_v1_compatible').checked = crypto_v1_compatible; }); document.getElementById('save').addEventListener("click", save);