Skip to content

Commit dd39551

Browse files
committed
feat: simple share fit watchlater and favlist
1 parent 985bec5 commit dd39551

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## 2.2.2
44

55
- 新增:顶栏 稍后再看相关选项
6-
- 新增:评论区规则适配稍后再看页面、收藏夹页面
6+
- 新增:评论区规则、净化分享适配稍后再看页面、收藏夹页面
77
- 优化:首页 隐藏下载桌面端弹窗 改为默认开启
88
- 优化:全屏下隐藏弹幕输入框,完整展示章节名
99
- 优化:用户开启开关时执行功能函数

src/pages/common.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ if (location.host != 'live.bilibili.com') {
707707
headerRightItems.push(
708708
new NormalItem(
709709
'common-hide-nav-favorite',
710-
'隐藏 收藏, 隐藏 稍后再看',
710+
'隐藏 收藏隐藏 稍后再看',
711711
false,
712712
undefined,
713713
false,
@@ -724,7 +724,7 @@ if (location.host != 'live.bilibili.com') {
724724
headerRightItems.push(
725725
new NormalItem(
726726
'common-hide-nav-favorite-keep-watchlater',
727-
'隐藏 收藏, 保留 稍后再看(实验性)',
727+
'隐藏 收藏,显示 稍后再看(实验性)',
728728
false,
729729
undefined,
730730
false,
@@ -750,7 +750,7 @@ if (location.host != 'live.bilibili.com') {
750750
headerRightItems.push(
751751
new NormalItem(
752752
'common-nav-keep-watchlater',
753-
'显示 收藏, 显示 稍后再看(实验性)',
753+
'显示 收藏显示 稍后再看(实验性)',
754754
false,
755755
undefined,
756756
false,

src/pages/video.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,26 @@ function simpleShare() {
6262
// 新增click事件
6363
// 若replace element, 会在切换视频后无法更新视频分享数量, 故直接新增click事件覆盖剪贴板
6464
shareBtn.addEventListener('click', () => {
65-
let title = document.querySelector('#viewbox_report > h1')?.textContent as string
65+
let title = document.querySelector('#viewbox_report > h1')?.textContent
66+
if (!title) {
67+
// 尝试稍后再看or收藏夹列表
68+
title = document.querySelector('.video-title-href')?.textContent
69+
if (!title) {
70+
return
71+
}
72+
}
6673
if (
6774
!'(({【[[《「<{〔〖<〈『'.includes(title[0]) &&
6875
!'))}】]]》」>}〕〗>〉』'.includes(title.slice(-1))
6976
) {
7077
title = `【${title}】`
7178
}
72-
let urlPath = location.pathname
73-
if (urlPath.endsWith('/')) {
74-
urlPath = urlPath.slice(0, -1)
75-
}
79+
// 匹配av号, BV号, 分P号
80+
const pattern = /av\d+|BV[1-9A-HJ-NP-Za-km-z]+/g
81+
const avbv = pattern.exec(location.href)
82+
let shareText = `${title} \nhttps://www.bilibili.com/video/${avbv}`
7683
const urlObj = new URL(location.href)
7784
const params = new URLSearchParams(urlObj.search)
78-
let shareText = `${title} \nhttps://www.bilibili.com${urlPath}`
7985
if (params.has('p')) {
8086
shareText += `?p=${params.get('p')}`
8187
}
@@ -759,7 +765,9 @@ if (
759765
false,
760766
undefined,
761767
false,
762-
`#v_desc {display: none !important;}`,
768+
`#v_desc {display: none !important;}
769+
/* 收藏夹和稍后再看 */
770+
.video-desc-container {display: none !important;}`,
763771
),
764772
)
765773
// 隐藏 tag列表
@@ -770,7 +778,9 @@ if (
770778
false,
771779
undefined,
772780
false,
773-
`#v_tag {display: none !important;}`,
781+
`#v_tag {display: none !important;}
782+
/* 收藏夹和稍后再看 */
783+
.video-tag-container {display: none !important;}`,
774784
),
775785
)
776786
// 隐藏 活动宣传, 默认开启

0 commit comments

Comments
 (0)