Fix live auto play (fix #1813)

This commit is contained in:
the1812 2021-05-06 14:35:12 +08:00
parent 51d644920b
commit 48d02073db
2 changed files with 10 additions and 9 deletions

View File

@ -1 +1 @@
(()=>(e,i)=>{(async()=>{const e=document.URL.replace(window.location.search,"");if(e!=="https://live.bilibili.com/"&&e!=="https://live.bilibili.com/index.html"){return}SpinQuery.condition((()=>document.querySelector(".component-ctnr video,.bilibili-live-player-video video")),(e=>e&&!e.paused),(()=>{const e=dq(".live-web-player-controller .left-area > :first-child");e===null||e===void 0?void 0:e.click()}));const i="hide-home-live-style";addSettingsListener("hideHomeLive",(e=>{if(e===true){const e=document.createElement("style");e.innerText=`.player-area-ctnr,#player-header { display: none !important }`;e.id=i;document.body.append(e)}else{const e=document.getElementById(i);e&&e.remove()}}),true)})()})();
(()=>(e,t)=>{(async()=>{const e=document.URL.replace(window.location.search,"");if(e!=="https://live.bilibili.com/"&&e!=="https://live.bilibili.com/index.html"){return}SpinQuery.select("video").then((e=>e.pause()));const t="hide-home-live-style";addSettingsListener("hideHomeLive",(e=>{if(e===true){const e=document.createElement("style");e.innerText=`.player-area-ctnr,#player-header { display: none !important }`;e.id=t;document.body.append(e)}else{const e=document.getElementById(t);e&&e.remove()}}),true)})()})();

View File

@ -3,14 +3,15 @@
if (url !== 'https://live.bilibili.com/' && url !== 'https://live.bilibili.com/index.html') {
return
}
SpinQuery.condition(
() => document.querySelector('.component-ctnr video,.bilibili-live-player-video video'),
(video: HTMLVideoElement) => video && !video.paused,
() => {
const button = dq('.live-web-player-controller .left-area > :first-child') as HTMLElement
button?.click()
}
)
// SpinQuery.condition(
// () => document.querySelector('.component-ctnr video,.bilibili-live-player-video video'),
// (video: HTMLVideoElement) => video && !video.paused,
// () => {
// const button = dq('.live-web-player-controller .left-area > :first-child') as HTMLElement
// button?.click()
// }
// )
SpinQuery.select('video').then((video: HTMLVideoElement) => video.pause())
const styleID = 'hide-home-live-style'
addSettingsListener('hideHomeLive', value => {
if (value === true) {