From cd1a6c9d709dd484bb98376667e08645316e2d0a Mon Sep 17 00:00:00 2001 From: Hakadao Date: Mon, 11 Sep 2023 18:00:37 +0800 Subject: [PATCH] fix: blank page when video is already playing --- src/contentScripts/index.ts | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/contentScripts/index.ts b/src/contentScripts/index.ts index fc5b7a1f..a592d525 100644 --- a/src/contentScripts/index.ts +++ b/src/contentScripts/index.ts @@ -36,8 +36,24 @@ if (isFirefox) { else { document.addEventListener('DOMContentLoaded', () => { injectApp() - window.onload = () => { - document.documentElement.removeChild(beforeLoadedStyleEl) + + const currentUrl = document.URL + if ( + // video page + /https?:\/\/(www.)?bilibili.com\/video\/.*/.test(currentUrl) + // watch later playlist + || /https?:\/\/(www.)?bilibili.com\/list\/watchlater.*/.test(currentUrl) + // favorite playlist + || /https?:\/\/(www.)?bilibili.com\/list\/ml.*/.test(currentUrl) + ) { + setTimeout(() => { + document.documentElement.removeChild(beforeLoadedStyleEl) + }, 800) + } + else { + window.onload = () => { + document.documentElement.removeChild(beforeLoadedStyleEl) + } } }) }