From 10bfc7cdbcab710491b330272e1e1f26f2057fce Mon Sep 17 00:00:00 2001 From: Hakadao Date: Sun, 14 Jan 2024 23:48:09 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20resolve=20=E7=BD=91=E9=A1=B5=E9=93=BE?= =?UTF-8?q?=E6=8E=A5=E6=89=93=E5=BC=80=E6=97=A0=E6=B3=95=E8=B7=B3=E8=BD=AC?= =?UTF-8?q?=E5=88=B0=E8=A7=86=E9=A2=91=E9=A1=B5=EF=BC=8C=E5=B9=B6=E4=B8=94?= =?UTF-8?q?=E4=B8=BB=E9=A2=98=E5=A4=B1=E6=95=88=20#166?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/contentScripts/index.ts | 2 ++ src/contentScripts/views/App.vue | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/contentScripts/index.ts b/src/contentScripts/index.ts index fa9fe869..29ff1599 100644 --- a/src/contentScripts/index.ts +++ b/src/contentScripts/index.ts @@ -32,6 +32,8 @@ function isSupportedPages() { || /https?:\/\/www.bilibili.com\/index.html$/.test(currentUrl) || /https?:\/\/bilibili.com\/\?spm_id_from=.*/.test(currentUrl) || /https?:\/\/www.bilibili.com\/\?spm_id_from=(.)*/.test(currentUrl) + // fix #166 https://github.com/hakadao/BewlyBewly/issues/166 + || /https?:\/\/www.bilibili.com\/\?bvid=.*$/.test(currentUrl) // video page || /https?:\/\/(www.)?bilibili.com\/video\/.*/.test(currentUrl) diff --git a/src/contentScripts/views/App.vue b/src/contentScripts/views/App.vue index f0bab678..1a628fc3 100644 --- a/src/contentScripts/views/App.vue +++ b/src/contentScripts/views/App.vue @@ -12,7 +12,7 @@ import WatchLater from './WatchLater/WatchLater.vue' import Favorites from './Favorites/Favorites.vue' import { accessKey, settings } from '~/logic' import { AppPage, LanguageType } from '~/enums/appEnums' -import { getUserID, hexToRGBA, isHomePage, smoothScrollToTop } from '~/utils/main' +import { getUserID, hexToRGBA, isHomePage, openLinkToNewTab, smoothScrollToTop } from '~/utils/main' import emitter from '~/utils/mitt' const activatedPage = ref(settings.value.dockItemVisibilityList.find(e => e.visible === true)?.page ?? AppPage.Home) @@ -91,6 +91,8 @@ watch(() => settings.value.adaptToOtherPageStyles, () => { }) onMounted(() => { + openVideoPageIfBvidExists() + if (isHomePage()) { // Force overwrite Bilibili Evolved body tag & html tag background color document.body.style.setProperty('background-color', 'unset', 'important') @@ -237,6 +239,20 @@ function handleOsScroll() { topBarRef.value?.handleScroll() } +// fix #166 https://github.com/hakadao/BewlyBewly/issues/166 +function openVideoPageIfBvidExists() { + // Assume the URL is https://www.bilibili.com/?bvid=BV1be41127ft&spm_id_from=333.788.seo.out + + // Get the current URL's query string + const queryString = window.location.search + // Create a URLSearchParams instance + const urlParams = new URLSearchParams(queryString) + const bvid = urlParams.get('bvid') + + if (bvid) + window.open(`https://www.bilibili.com/video/${bvid}`, '_self') +} + provide('handleBackToTop', handleBackToTop) provide('handleRefresh', handleRefresh) provide('activatedPage', activatedPage)