front/js/qv.min.js
2024-08-31 02:50:04 +08:00

1 line
2.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

let client;async function f1(){try{var e=await(await fetch("https://download.xn--xhq44jb2fzpc.com/upload/json/s.json")).json(),t=e.masterKey,o=CryptoJS.SHA256(t),n={region:d2(e.encryptedRegion,o),accessKeyId:d2(e.encryptedKeyId,o),accessKeySecret:d2(e.encryptedKeySecret,o),bucket:d2(e.encryptedBucket,o)};client=new OSS(n)}catch(e){console.error("Failed to fetch or decrypt OSS config:",e)}}function d2(e,t){e=e.replace(/\s/g,"");var e=CryptoJS.enc.Base64.parse(e),o=CryptoJS.lib.WordArray.create(e.words.slice(0,4)),e=CryptoJS.lib.WordArray.create(e.words.slice(4));return CryptoJS.AES.decrypt({ciphertext:e},t,{iv:o,mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7}).toString(CryptoJS.enc.Utf8)}function getCookie(e){var o=e+"=",n=document.cookie.split(";");for(let t=0;t<n.length;t++){let e=n[t];for(;" "==e.charAt(0);)e=e.substring(1,e.length);if(0==e.indexOf(o))return e.substring(o.length,e.length)}return null}document.addEventListener("DOMContentLoaded",function(){f1().then(()=>{client||console.error("Failed to initialize OSS client due to decryption error.")}).catch(e=>{console.log("Error initializing OSS Client:",e)})});let loggedIn=getCookie("loggedIn"),email=getCookie("userEmail");if(loggedIn&&email){let e=async()=>{try{var e=await fetch(`https://download.xn--xhq44jb2fzpc.com/user/${email}/qv.json`);e.ok&&!0===await e.json()&&(alert("您已经完成验证,无需再次验证!"),window.location.href="/submission")}catch(e){console.log("没有找到验证文件,继续验证流程。")}};e(),document.getElementById("verifybtn").addEventListener("click",async()=>{try{if((await(await fetch("https://ipquery.xn--xhq44jb2fzpc.com/api/check-ip")).json()).data.isInNeU){var e=new Blob([JSON.stringify(!0)],{type:"application/json"});try{await client.put(`user/${email}/qv.json`,e),alert("您已完成验证!"),window.location.href="/submission"}catch(e){console.error("OSS写入失败:",e),alert("验证失败,请稍后重试。")}}else alert("您未连接NEU校园网请连接后重试")}catch(e){console.error("IP验证失败:",e),alert("验证失败,请稍后重试。")}})}else alert("您未登录,请先登录后操作!"),window.location.href="/submission";