// options.js

document.addEventListener("DOMContentLoaded", async () => {
  const options = await loadOptions();

  document.getElementById("state-selector").value = options.state || "";
  document.getElementById("pdf-path").value = options.pdfPath || "cookiekop/pdfs/";
  document.getElementById("screenshot-path").value = options.screenshotPath || "cookiekop/screenshots/";
  document.getElementById("show-banner").checked = options.showBanner ?? true;
  document.getElementById("share-stats").checked = options.shareStats ?? false;

  document.getElementById("save-options").addEventListener("click", saveOptions);
});

// Optionen speichern
async function saveOptions() {
  const options = {
    state: document.getElementById("state-selector").value,
    showBanner: document.getElementById("show-banner").checked
    // pdfPath und screenshotPath werden NICHT mehr gespeichert!
  };
  await chrome.storage.local.set({ options });
  alert("Einstellungen gespeichert!");
}

// Optionen laden
async function loadOptions() {
  const result = await chrome.storage.local.get('options');
  return result.options || {};
}