Fix bpx-player-adaptor (PR #237

fix #2366, fix #2304
This commit is contained in:
the1812 2021-10-08 13:10:02 +08:00
parent 7c18801804
commit b86406e61d
2 changed files with 2 additions and 2 deletions

View File

@ -1 +1 @@
(()=>(e,t)=>{const n=async()=>{const e=await SpinQuery.select(".bpx-player-container");if(!e){console.warn("[bpx player polyfill] bpxContainer not found");return}Observer.attributes(e,(()=>{const t=e.getAttribute("data-screen");document.body.classList.toggle("player-mode-webfullscreen",t==="full"||t==="web");document.body.classList.toggle("player-mode-widescreen",t==="wide")}))};const o=async()=>{const e=await SpinQuery.select((()=>unsafeWindow.$pbp));if(!e){console.warn("[bpx player polyfill] pbp not found");return}const t={aid:e.options.aid.toString(),cid:e.options.cid.toString(),bvid:e.options.bvid};if(Object.values(t).some((e=>e===""||parseInt(e)<=0))){console.warn("[bpx player polyfill] invalid pbp data")}Object.assign(unsafeWindow,t)};const i=async()=>{if(!document.URL.startsWith("https://www.bilibili.com/bangumi/play/")){return}n();o()};return{export:{bpxPlayerPolyfill:i}}})();
(()=>(e,t)=>{const n=async()=>{const e=await SpinQuery.select(".bpx-player-container");if(!e){console.warn("[bpx player polyfill] bpxContainer not found");return}Observer.attributes(e,(()=>{const t=e.getAttribute("data-screen");document.body.classList.toggle("player-mode-webfullscreen",t==="full"||t==="web");t==="wide"?document.body.classList.add("player-mode-widescreen"):""}))};const o=async()=>{const e=await SpinQuery.select((()=>unsafeWindow.$pbp));if(!e){console.warn("[bpx player polyfill] pbp not found");return}const t={aid:e.options.aid.toString(),cid:e.options.cid.toString(),bvid:e.options.bvid};if(Object.values(t).some((e=>e===""||parseInt(e)<=0))){console.warn("[bpx player polyfill] invalid pbp data")}Object.assign(unsafeWindow,t)};const i=async()=>{if(!document.URL.startsWith("https://www.bilibili.com/bangumi/play/")){return}n();o()};return{export:{bpxPlayerPolyfill:i}}})();

View File

@ -8,7 +8,7 @@ const playerModePolyfill = async () => {
Observer.attributes(bpxContainer, () => {
const dataScreen = bpxContainer.getAttribute('data-screen')
document.body.classList.toggle('player-mode-webfullscreen', dataScreen === 'full' || dataScreen === 'web')
document.body.classList.toggle('player-mode-widescreen', dataScreen === 'wide')
dataScreen === 'wide' ? document.body.classList.add('player-mode-widescreen') : ''
})
}
const idPolyfill = async () => {