(()=>(e,t)=>{if(typeof isEmbeddedPlayer!=="undefined"&&isEmbeddedPlayer()){return}const a=["https://www.bilibili.com/video/","https://www.bilibili.com/watchlater/","https://www.bilibili.com/medialist/play/","https://www.bilibili.com/bangumi/play/"];if(!a.some((e=>document.URL.startsWith(e)))){return}const n=[{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 i=()=>{};let o=()=>{};async function s(){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")};i=()=>t(true);o=()=>t(false)}}async function r(){await s();const{playerReady:a}=await t.importAsync("player-ready");const{playerAgent:r}=await t.importAsync("player-agent");await a();Observer.videoChange((async()=>{const e=await r.query.video.element();if(!e){return}if(d){i()}e.addEventListener("ended",o);e.addEventListener("pause",o);e.addEventListener("play",i)}));const c=await r.query.video.element();if(!c){return}const l=n.find((t=>t.name===e.defaultPlayerMode));const y=async()=>{const e=!dq("body[class*=player-mode-]");if(l&&e){l.action()}};const d=_.get(JSON.parse(localStorage.getItem("bilibili_player_settings")),"video_status.autoplay",false);if(e.applyPlayerModeOnPlay&&!d){c.addEventListener("play",y,{once:true})}else{y()}}r()})();