feat: 添加稍后再看页面重定向组件

This commit is contained in:
magicFeirl 2025-04-09 13:54:14 +08:00
parent 4e8221f089
commit fbbe32fc35
2 changed files with 31 additions and 0 deletions

View File

@ -0,0 +1 @@
重定向**稍后再看页面**到普通视频页面,和`稍后再看重定向`组件的区别在于,该组件是在进入稍后再看的视频页面后进行重定向,而非直接替换链接到普通视频的链接,用于补充`稍后再看重定向`组件的功能。

View File

@ -0,0 +1,30 @@
import { ComponentEntry } from '@/components/types'
import { defineComponentMetadata } from '@/components/define'
const getBvidFromWatcherLaterVideoPage = () => {
const { pathname, search } = window.location
const oidAndBvid = search.match(/\?oid=(\d+)&bvid=(\w+)/) ?? []
if (pathname === '/list/watchlater' && oidAndBvid.length === 3) {
return oidAndBvid[2]
}
return null
}
const entry: ComponentEntry = async () => {
// 判断是否是稍后再看链接格式的视频页面,如果是则重定向
const bvid = getBvidFromWatcherLaterVideoPage()
if (bvid) {
location.href = `https://www.bilibili.com/video/${bvid}`
}
}
export const component = defineComponentMetadata({
name: 'watchlaterPageRedirect',
displayName: '稍后再看页面-重定向',
entry,
urlInclude: ['https://www.bilibili.com/list/watchlater'],
tags: [componentsTags.utils, componentsTags.video],
})