// Saves options to chrome.storage
async function save_options() {
  let rules = document.getElementById('rules').value;

  await chrome.storage.sync.set({ rules });
  alert('rules saved');
}


async function restore_options() {
  let { rules, blacklist } = await chrome.storage.sync.get(["rules", "blacklist"]);

  document.getElementById('rules').value = rules || '';
  document.getElementById('blacklist').value = blacklist || '';
}

document.addEventListener('DOMContentLoaded', restore_options);

document.getElementById('save').addEventListener('click', save_options);
document.getElementById('saveBlacklist').addEventListener('click', save_blacklist);

async function save_blacklist() {
  let blacklist = document.getElementById('blacklist').value;

  await chrome.storage.sync.set({ blacklist });
  
  alert('blacklist saved');
}
