mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
1 line
1.9 KiB
JavaScript
1 line
1.9 KiB
JavaScript
(()=>(e,t)=>{if(typeof isEmbeddedPlayer!=="undefined"&&isEmbeddedPlayer()){return}const a=[{name:"常规",action:()=>{}},{name:"宽屏",action:async()=>{const{playerAgent:e}=await t.importAsync("player-agent");await e.widescreen()}},{name:"网页全屏",action:async()=>{const{playerAgent:e}=await t.importAsync("player-agent");await e.webFullscreen()}},{name:"全屏",action:async()=>{const{playerAgent:e}=await t.importAsync("player-agent");const a=await SpinQuery.condition((()=>document.querySelector(e.query.video.element.selector)),(e=>e!==null&&e.readyState===4&&document.readyState==="complete"&&document.hasFocus()));if(a===null){console.warn("[默认播放器模式] 未能应用全屏模式, 等待超时.");return}await e.fullscreen()}}];let n=()=>{};let i=()=>{};async function r(){const{playerAgent:a}=await t.importAsync("player-agent");if(e.autoLightOff){await SpinQuery.unsafeJquery();const e=await a.query.control.buttons.settings();if(!e){return}e.mouseover().mouseout();const t=async e=>{const t=await SpinQuery.select(".bilibili-player-video-btn-setting-right-others-content-lightoff .bui-checkbox-input");t.checked=e;raiseEvent(t,"change")};n=()=>t(true);i=()=>t(false)}}async function o(){await r();const{playerReady:o}=await t.importAsync("player-ready");const{playerAgent:s}=await t.importAsync("player-agent");await o();const c=await s.query.video.element();if(!c){return}const l=a.find((t=>t.name===e.defaultPlayerMode));const y=async()=>{const e=await s.query.bilibiliPlayer();const t=e.getAttribute("data-screen");const a=!e.className.includes("mode-")&&(t===null||t==="normal");if(l&&a){l.action()}};const u=_.get(JSON.parse(localStorage.getItem("bilibili_player_settings")),"video_status.autoplay",false);if(e.applyPlayerModeOnPlay&&!u){c.addEventListener("play",y,{once:true})}else{y()}if(u){n()}c.addEventListener("ended",i);c.addEventListener("pause",i);c.addEventListener("play",n)}Observer.videoChange(o)})(); |