Bilibili-Evolved/min/frame-playback.min.js

1 line
1.2 KiB
JavaScript

(()=>{return(e,t)=>{const r=t.import("framePlaybackHtml");t.applyStyle("framePlaybackStyle");const i=async()=>{const e=await SpinQuery.select(()=>document.querySelector("video"));const t=await SpinQuery.select(()=>document.querySelector(".bilibili-player-video-time"));if(t===null||document.querySelector(".frame-playback")){return}t.insertAdjacentHTML("afterend",r);let i=0;const n=()=>e.currentTime-=i;const a=()=>e.currentTime+=i;Observer.attributesSubtree(".bilibili-player-video-quality-menu ul.bui-select-list",()=>{const e=document.querySelector(".bilibili-player-video-quality-menu .bui-select-item-active");const t=e?parseInt(e.getAttribute("data-value")):0;const r=(()=>{switch(t){case 116:case 74:return 6e4/1001;default:return 3e4/1001}})();i=1/r});document.addEventListener("keydown",e=>{if(e.shiftKey&&!["input","textarea"].includes(document.activeElement.nodeName.toLowerCase())){if(e.key==="ArrowLeft"){e.stopPropagation();e.preventDefault();n()}else if(e.key==="ArrowRight"){e.stopPropagation();e.preventDefault();a()}}});document.querySelector(".prev-frame").addEventListener("click",n);document.querySelector(".next-frame").addEventListener("click",a)};Observer.videoChange(i)}})();