Bilibili-Evolved/min/default-player-mode.min.js

1 line
849 B
JavaScript

(()=>{return(e,n)=>{const t=[{name:"常规",actionButtonSelector:""},{name:"宽屏",actionButtonSelector:".bilibili-player-video-btn-widescreen"},{name:"网页全屏",actionButtonSelector:".bilibili-player-video-web-fullscreen"}];SpinQuery.any(()=>$(".gui-settings-dropdown:has(input[key=defaultPlayerMode])"),e=>{const n=e.find("ul");const i=e.find("input");Object.values(t).forEach(e=>{$(`<li>${e.name}</li>`).appendTo(n).on("click",()=>{i.val(e.name).trigger("input").change()})})});new SpinQuery(()=>$(".bilibili-player-video"),e=>e.length>0&&$("video").length>0&&$("video").prop("duration"),()=>{const n=document.querySelector("video");const i=()=>{const o=t.find(n=>n.name===e.defaultPlayerMode);if(!o){return}if(o.name!=="常规"){$(o.actionButtonSelector).click()}n.removeEventListener("play",i)};n.addEventListener("play",i)}).start()}})();