diff --git a/index.html b/index.html index 0e079b2..81b3c3f 100644 --- a/index.html +++ b/index.html @@ -430,7 +430,7 @@

去全部歌单里添加一些吧

showLoadingTip: false } let startTime = Date.now(); - await loadScriptAsync("https://gen2.qinlili.bid/libs/hamood.min.js"); + await loadScriptAsync("./lib/hamood.min.js"); let loadUseTime = Date.now() - startTime; Hamood.init(hamoodConfig, (loadUseTime >= 500)); })(); @@ -726,7 +726,7 @@

去全部歌单里添加一些吧

dlHiMenu.addEventListener("click", async () => { if (!window.ctfile) { setStatus("加载城通网盘解析模块", true); - await loadScriptAsync("https://ctfile.qinlili.bid/ctget.js"); + await loadScriptAsync("./lib/ctget.min.js"); } setStatus("获取下载地址", true); let fileInfo = await window.ctfile.getByID(songInfo.hi_res_id, "547873715"); diff --git a/lib/ctget.min.js b/lib/ctget.min.js new file mode 100644 index 0000000..6bdb77a --- /dev/null +++ b/lib/ctget.min.js @@ -0,0 +1 @@ +window.ctfile={version:()=>"2.3.0",getByLink:(link,password)=>ctfile.getByID(link.slice(link.lastIndexOf("/")+1),password),getByID:async(fileid,password)=>{const origin=()=>document&&"file://"!=document.location.origin?document.location.origin:"https://ctfile.qinlili.workers.dev",path=id=>{switch(id.split("-").length){case 2:return"file";case 3:default:return"f"}};return jsonText=JSON.parse(await(await fetch("https://webapi.ctfile.com/getfile.php?path="+path(fileid)+"&f="+fileid+"&passcode="+password+"&token=false&r="+Math.random()+"&ref="+origin(),{headers:{origin:origin(),referer:origin()}})).text()),200==jsonText.code?(jsonText2=JSON.parse(await(await fetch("https://webapi.ctfile.com/get_file_url.php?uid="+jsonText.file.userid+"&fid="+jsonText.file.file_id+"&file_chk="+jsonText.file.file_chk+"&app=0&acheck=2&rd="+Math.random(),{headers:{origin:origin(),referer:origin()}})).text()),200==jsonText2.code?{success:!0,name:jsonText.file.file_name,size:jsonText.file.file_size,time:jsonText.file.file_time,link:jsonText2.downurl}:{success:!1,name:jsonText.file.file_name,size:jsonText.file.file_size,time:jsonText.file.file_time,errormsg:jsonText2.message}):{success:!1,errormsg:jsonText.file.message}}}; \ No newline at end of file diff --git a/lib/hamood.min.js b/lib/hamood.min.js new file mode 100644 index 0000000..e9271df --- /dev/null +++ b/lib/hamood.min.js @@ -0,0 +1 @@ +(()=>{const HamoodDiv='

跳过

',ratio=window.innerWidth/window.innerHeight;let storageData=localStorage.hamood?JSON.parse(localStorage.hamood):{};const updateStorage=()=>{localStorage.hamood=JSON.stringify(storageData)},sleep=delay=>new Promise(resolve=>setTimeout(resolve,delay));let picCache;const waitToExit=async showTime=>{const text=document.getElementById("hamoodSkip");for(text.addEventListener("click",()=>{closeHamood()});showTime>0;showTime--)text.innerText="跳过 "+showTime+"秒",await sleep(1e3);closeHamood()},closeHamood=async()=>{document.getElementById("hamood").style.opacity=0,await sleep(500),document.body.removeChild(document.getElementById("hamood")),updateStorage()},updateSplashAsync=async url=>{await sleep(6e4);let splash=await(await fetch(url).catch(()=>{console.error("Failed to load Hamood data.")})).json().catch(()=>{console.error("Failed to load Hamood data.")}),selected;if(storageData.cachedSplash=splash,storageData.cachedUrl=url,storageData.cachedSplash.splash.forEach(pic=>{pic.minRatio{"navigation"==!performance.getEntriesByType("navigation")[0].type&&(console.log("Not new open page, skip Hamood."),skip=!0),console.log("Hamood Version:0.1.3");let startTime=Date.now(),selected;if(storageData.cachedSplash&&!storageData.cachedUrl!=config.data)updateSplashAsync(config.data);else{let splash=await(await fetch(config.data).catch(()=>{console.error("Failed to load Hamood data.")})).json().catch(()=>{console.error("Failed to load Hamood data.")});storageData.cachedSplash=splash,storageData.cachedUrl=config.data}if(Date.now()-startTime>500&&(skip=!0),storageData.showHistory=storageData.showHistory?storageData.showHistory:{},picCache=await caches.open("Hamood"),storageData.cachedSplash.splash.forEach(pic=>{pic.minRatio{window.open(selected.link,"_blank")});let cacheRequest=await fetch(selected.pic);cacheRequest.status<300?picCache.put(selected.pic,cacheRequest.clone()):console.warn("Splash url returned code "+cacheRequest.status+". Check your url."),picDiv.src=URL.createObjectURL(await cacheRequest.blob()),picDiv.onload=()=>{picDiv.style.opacity=1,document.getElementById("hamoodLoading").style.display="none",storageData.showHistory[selected.name].repeat++,storageData.showHistory[selected.name].lastDay==(new Date).toLocaleDateString()?storageData.showHistory[selected.name].dailyRepeat++:(storageData.showHistory[selected.name].lastDay=(new Date).toLocaleDateString(),storageData.showHistory[selected.name].dailyRepeat=1),waitToExit(selected.showTime)},document.getElementById("hamoodText").innerText=selected.text}else{skip=!0;let cacheRequest=await fetch(selected.pic);cacheRequest.status<300?picCache.put(selected.pic,cacheRequest.clone()):console.warn("Splash url returned code "+cacheRequest.status+". Check your url.")}if(!skip&&picFile){document.body.insertAdjacentHTML("beforeend",HamoodDiv);let picDiv=document.getElementById("hamoodSplash");picDiv.src=URL.createObjectURL(await picFile.blob()),picDiv.onload=()=>{picDiv.style.opacity=1,storageData.showHistory[selected.name].repeat++,storageData.showHistory[selected.name].lastDay==(new Date).toLocaleDateString()?storageData.showHistory[selected.name].dailyRepeat++:(storageData.showHistory[selected.name].lastDay=(new Date).toLocaleDateString(),storageData.showHistory[selected.name].dailyRepeat=1),waitToExit(selected.showTime)};let textDiv=document.getElementById("hamoodText");textDiv.innerText=selected.text,textDiv.addEventListener("click",()=>{window.open(selected.link,"_blank")})}}else console.warn("No splash avaliable for Hamood.");updateStorage()},clearHistory:name=>{name?delete storageData.showHistory[name]:storageData.showHistory={},updateStorage()}}})(); \ No newline at end of file