mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
1 line
2.4 KiB
JavaScript
1 line
2.4 KiB
JavaScript
(()=>{return(t,i)=>{const{NavbarComponent:s}=i.import("custom-navbar-component");class e extends s{constructor({mainUrl:t,name:i,apiUrl:s,listName:e,listMap:a}){super();this.href=t;this.listName=e;this.html=i;this.noPadding=true;this.requestedPopup=false;this.popupHtml=`\n<ol class="video-list ${e}">\n<li class="loading">加载中...</li>\n</ol>\n`;this.initialPopup=(async()=>{if(!a){return}const l=await SpinQuery.select(`.video-list.${e}`);if(l===null){return}const r=await Ajax.getJsonWithCredentials(s);let n="";if(r.code!==0){logError(`加载${i}信息失败. 错误码: ${r.code} ${r.message}`)}else{n=a(r).join("")}l.insertAdjacentHTML("beforeend",n+`\n<li class="more"><a target="_blank" href="${t}">查看更多</a></li>\n`);l.classList.add("loaded")})}get name(){return this.listName+"List"}}class a extends e{constructor(){super({name:"收藏",mainUrl:`https://space.bilibili.com/${getUID()}/favlist`,apiUrl:"https://api.bilibili.com/medialist/gateway/coll/resource/recent",listName:"favorites",listMap:t=>{if(!t.data||t.data.length===0){return[`<li class="loading empty">空空如也哦 = ̄ω ̄=</li>`]}return t.data.map(t=>{return`\n<li>\n<a target="_blank" href="https://www.bilibili.com/video/av${t.id}">${t.title}</a>\n</li>`})}});this.active=document.URL.replace(/\?.*$/,"")===`https://space.bilibili.com/${getUID()}/favlist`}}class l extends e{constructor(){super({name:"历史",mainUrl:"https://www.bilibili.com/account/history",apiUrl:"https://api.bilibili.com/x/v2/history?pn=1&ps=6",listName:"history",listMap:t=>{if(!t.data||t.data.length===0){return[`<li class="loading empty">空空如也哦 = ̄ω ̄=</li>`]}return t.data.map(t=>{let i=[];let s="";const e=t.page?t.page.page:1;let a=t.progress>=0?t.progress/t.duration:1;if(isNaN(a)){a=0}if(e!==1){i.push(`p=${e}`);s+=`看到第${e}话`}if(t.progress>0&&t.progress<t.duration){i.push(`t=${t.progress}`);s+=` ${Math.floor(a*100)}%`}else if(t.progress===0){s+=` 刚开始看`}else{s+=" 100%"}return`\n<li class="history-item">\n<a target="_blank" href="https://www.bilibili.com/video/av${t.aid}?${i.join("&")}">\n<span class="title">${t.title}</span>\n<span class="description">${s}</span>\n<div class="progress background">\n<div class="progress foreground" style="--progress: ${a*100}%"></div>\n</div>\n</a>\n</li>`})}});this.active=document.URL.replace(/\?.*$/,"")==="https://www.bilibili.com/account/history"}}return{export:{FavoritesList:a,HistoryList:l}}}})(); |