mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
1 line
1.1 KiB
JavaScript
1 line
1.1 KiB
JavaScript
(()=>{return(e,t)=>{let n=true;const r="airborneStyle";(async()=>{if(!document.URL.match(/\/\/www\.bilibili\.com\/video\//)){return}const{forEachVideoDanmaku:e}=await t.importAsync("video-danmaku");t.applyStyle(r);const a=e=>{if(!e){return NaN}const t=e.match(/(\d+)[ ]*[::.][ ]*(\d+)([ ]*[::][ ]*(\d+))?/);if(!t){return NaN}if(t[3]){const[,e,n,,r]=t.map(e=>parseInt(e));if([e,n,r].some(e=>Number.isNaN(e))){return NaN}return e*3600+n*60+r}const[,n,r]=t.map(e=>parseInt(e));if([n,r].some(e=>Number.isNaN(e))){return NaN}return n*60+r};const i=e=>{if(!n){return}const t=e.target;if(!t.classList.contains("b-danmaku")){return}const r=a(t.textContent);if(!Number.isNaN(r)){const e=dq("video");e.currentTime=r;e.play()}};const s=e=>{const t=!Number.isNaN(a(e.text));e.element.classList.toggle("airborne",t)};e({added:s});Observer.videoChange(async()=>{const e=await SpinQuery.select(".bilibili-player-video-wrap");if(e.classList.contains("airborne-enabled")){return}e.classList.add("airborne-enabled");e.addEventListener("click",i)})})();return{reload:()=>{n=true;t.applyStyle(r)},unload:()=>{n=false;t.removeStyle(r)}}}})(); |