mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
1 line
849 B
JavaScript
1 line
849 B
JavaScript
(()=>(e,o)=>{const t={include:["//www.bilibili.com/video/","//www.bilibili.com/bangumi/"]};const n="showCoverBeforePlayStyle";let r;const i=()=>{if(t.include.every((e=>!document.URL.includes(e)))){return}o.applyStyle(n);const e=()=>document.body.style.removeProperty("--cover-url");const i=HTMLVideoElement.prototype.play;HTMLVideoElement.prototype.play=function(...o){e();return i.call(this,...o)};const l=async()=>{const e=await SpinQuery.select((()=>unsafeWindow.aid));if(!e){console.warn("[播放前显示封面] 未找到av号");return}const{cid:t}=unsafeWindow;if(t===r||!t){return}r=t;const{VideoInfo:n}=await o.importAsync("video-info");const i=new n(e);await i.fetchInfo();document.body.style.setProperty("--cover-url",`url('${i.coverUrl}')`)};Observer.videoChange(l)};i();return{reload:()=>o.applyStyle(n),unload:()=>o.removeStyle(n)}})(); |