50598de073b88fd597049ceca8d3966bacc9a149
   1function save_options() {
   2  var bgvalue = document.getElementById('bg').value;
   3  var fgvalue = document.getElementById('fg').value;
   4  var hrvalue = document.getElementById('hr').value;
   5  console.log(bgvalue);
   6
   7  chrome.storage.sync.set({
   8    "bgvalue": bgvalue,
   9    "fgvalue": fgvalue,
  10    "hrvalue": hrvalue,
  11  }, function() {
  12    window.close();
  13
  14  });
  15}
  16
  17
  18function restore_options() {
  19  chrome.storage.sync.get({
  20    "bgvalue": "#2e3440",
  21    "fgvalue": "#d8dee9",
  22    "hrvalue": "#434c5e"
  23  },
  24    function(items) {
  25      document.getElementById('bg').value = items["bgvalue"];
  26      document.getElementById('fg').value = items["fgvalue"];
  27      document.getElementById('hr').value = items["hrvalue"];
  28    });
  29}
  30
  31document.addEventListener('DOMContentLoaded', restore_options);
  32document.getElementById('save').addEventListener('click', save_options);