front/js/dl.min.js
2024-09-01 07:27:14 +08:00

1 line
1.5 KiB
JavaScript

let client;async function fetchNoCache(e){var t=(new Date).getTime();return fetch(e+"?timestamp="+t)}async function f1(){try{var e=await(await fetchNoCache("https://download.xn--xhq44jb2fzpc.com/download/json/s.json")).json(),t=e.masterKey,n=CryptoJS.SHA256(t),o={region:d2(e.encryptedRegion,n),accessKeyId:d2(e.encryptedKeyId,n),accessKeySecret:d2(e.encryptedKeySecret,n),bucket:d2(e.encryptedBucket,n)};client=new OSS(o)}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),n=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:n,mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7}).toString(CryptoJS.enc.Utf8)}document.addEventListener("DOMContentLoaded",function(){window.initializeDownloadLink=(e,t,o)=>{e=document.getElementById(e);let c=document.getElementById(t),r=c.querySelector(".popup-content");e.addEventListener("click",function(){let n=3;f1().then(()=>{if(client){let e=client.signatureUrl(o,{expires:20,response:{"content-disposition":"attachment"}}).replace("emberimg.oss-cn-beijing.aliyuncs.com","download.xn--xhq44jb2fzpc.com"),t=()=>{0<n?(r.textContent=n+"秒后将开始下载...",n--,setTimeout(t,1e3)):(c.style.display="none",window.location.href=e)};c.style.display="block",t()}else console.error("Failed to initialize OSS client due to decryption error.")}).catch(e=>{console.log("Error initializing OSS Client:",e)})})}});