-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings.js
More file actions
1 lines (1 loc) · 2.75 KB
/
Copy pathsettings.js
File metadata and controls
1 lines (1 loc) · 2.75 KB
1
import"./chunks/modulepreload-polyfill-YP0FEG5d.js";import{l as e,n as t,s as n}from"./chunks/extension-settings-fQcMQRZb.js";function o(e,t=!1){const n=document.createElement("div");n.className="toast "+(t?"error":""),n.textContent=e,document.body.appendChild(n),setTimeout(()=>n.classList.add("show"),100),setTimeout(()=>{n.classList.remove("show"),setTimeout(()=>n.remove(),300)},3e3)}document.addEventListener("DOMContentLoaded",async()=>{!function(){const e=document.getElementById("themeToggle"),t=document.documentElement;let n=localStorage.getItem("settings-theme");const o=e=>{"dark"===e?t.setAttribute("data-theme","dark"):"light"===e?t.removeAttribute("data-theme"):window.matchMedia("(prefers-color-scheme: dark)").matches?t.setAttribute("data-theme","dark"):t.removeAttribute("data-theme")};o(n),e?.addEventListener("click",()=>{const e="dark"===t.getAttribute("data-theme");n=e?"light":"dark",localStorage.setItem("settings-theme",n),o(n)})}(),function(){const e=document.querySelectorAll(".sidebar-nav a"),t=Array.from(e).map(e=>{const t=e.getAttribute("href");return t?document.querySelector(t):null}).filter(e=>null!==e),n=()=>{let n=t[0];for(const e of t)e.getBoundingClientRect().top<=120&&(n=e);e.forEach(e=>{e.classList.toggle("active",e.getAttribute("href")===`#${n.id}`)})};window.addEventListener("scroll",n,{passive:!0}),n()}();const a=await e(),r=document.getElementById("autoImport"),c=document.getElementById("showNotifications"),d=document.getElementById("enableAdvancedMode"),s=document.getElementById("defaultFormat"),l=document.getElementById("transparentBackgroundColorPicker"),u=document.getElementById("transparentBackgroundColor");r&&(r.checked=a.autoImport),c&&(c.checked=a.showNotifications),d&&(d.checked=a.enableAdvancedMode),s&&(s.value=a.defaultFormat),l&&(l.value=a.transparentBackgroundColor),u&&(u.value=a.transparentBackgroundColor),l&&u&&function(e,n,o){const a=()=>{const a=t(o.value);a&&(o.value=a,n.value=a,e.transparentBackgroundColor=a)};n.addEventListener("input",()=>{const a=t(n.value);a&&(o.value=a,e.transparentBackgroundColor=a)}),o.addEventListener("input",a),o.addEventListener("blur",a),document.querySelectorAll(".color-preset").forEach(a=>{a.addEventListener("click",()=>{const r=t(a.dataset.color??"");r&&(o.value=r,n.value=r,e.transparentBackgroundColor=r)})})}(a,l,u);const i=document.getElementById("savePreferences");i&&i.addEventListener("click",async()=>{a.autoImport=r?.checked??!0,a.showNotifications=c?.checked??!0,a.enableAdvancedMode=d?.checked??!0,a.defaultFormat=s?.value||"png";const e=t(u?.value??"");if(!e)return void o("Please enter a valid hex color (e.g. #FFFFFF).",!0);a.transparentBackgroundColor=e,u&&(u.value=e),l&&(l.value=e);await n(a)?o("Preferences saved successfully!"):o("Error saving preferences. Please try again.",!0)})});