Bilibili-Evolved/min/default-player-mode.min.js
2019-03-10 23:20:31 +08:00

1 line
1.8 KiB
JavaScript

(()=>{return(e,i)=>{const n=[{name:"常规",action:()=>{}},{name:"宽屏",action:()=>{$(".bilibili-player-video-btn-widescreen").click();document.querySelector("#bofqi").scrollIntoView({behavior:"smooth"})}},{name:"网页全屏",action:()=>{$(".bilibili-player-video-web-fullscreen").click()}}];let t=()=>{};let l=()=>{};async function a(){if(e.autoLightOff){await SpinQuery.unsafeJquery();const e=await SpinQuery.any(()=>unsafeWindow.$(".bilibili-player-video-btn-setting"));if(!e){return}e.mouseover().mouseout();const i=async e=>{const i=await SpinQuery.select(()=>document.querySelector(".bilibili-player-video-btn-setting-panel-others-content-lightoff .bui-checkbox-input"));i.checked=e;raiseEvent(i,"change")};t=(()=>i(true));l=(()=>i(false))}}async function o(){await a();await SpinQuery.condition(()=>$(".bilibili-player-video,.bilibili-player-video-btn-start,.bilibili-player-area"),e=>e.length===3&&$("video").length>0&&$("video").prop("duration"));const i=document.querySelector("video");if(!i){return}const o=n.find(i=>i.name===e.defaultPlayerMode);if(o.name==="全屏"){const e=await SpinQuery.unsafeJquery();const i=document.querySelector(".bilibili-player-video-btn-start");const n=()=>{const t=e(".bilibili-player-video-btn-fullscreen").data("events");if(t.click&&t.click[0]&&t.click[0].handler){const i=e(".bilibili-player-video-btn-fullscreen").data("events").click[0].handler;console.log(i);i()}i.removeEventListener("click",n)};i.addEventListener("click",n)}else{const n=()=>{if(o&&$("#bilibiliPlayer[class*=mode-]").length===0){o.action()}if(e.applyPlayerModeOnPlay){i.removeEventListener("play",n)}i.addEventListener("play",t);i.addEventListener("ended",l)};if(e.applyPlayerModeOnPlay){i.addEventListener("play",n)}else{n()}}}if(Observer.videoChange){Observer.videoChange(o)}else{Observer.childList("#bofqi",()=>o())}}})();