const getToken=()=>new Promise(e=>{chrome.storage.local.get({token:null},function(o){let t=o.token;e(t)})});document.addEventListener("DOMContentLoaded",async function(){const e=document.getElementById("toggle"),o=document.querySelector(".toggle-text");chrome.storage.local.get("type",function(t){"manual"===(t.type||"auto")?(e.checked=!0,o.textContent="插件模式"):(e.checked=!1,o.textContent="自动模式")}),e.addEventListener("change",function(){this.checked?(chrome.storage.local.set({type:"manual"},function(){console.log("type saved")}),o.textContent="插件模式",console.log("Toggle is ON")):(chrome.storage.local.set({type:"auto"},function(){console.log("type saved")}),o.textContent="自动模式")}),loginForm=document.getElementById("loginForm");const t=await getToken();console.log(t),loginForm.style.display=t?"none":"block",loginForm.addEventListener("submit",function(e){e.preventDefault();var o=document.getElementById("username").value,t=document.getElementById("password").value;console.log("用户名:",o),console.log("密码:",t),fetch(`https://apis.oneli.chat/v1/selectproduct/login?name=${o}&password=${t}`,{method:"GET",headers:{"Content-Type":"application/json"}}).then(e=>e.json()).then(e=>{console.log(e),200==e.code&&(console.log(e.token),chrome.storage.local.set({token:e.token},function(){console.log("Token saved")}),loginForm.style.display="none")})}),document.getElementById("open-chat").addEventListener("click",()=>{loginForm.style.display="block"})});