Skip to content

Commit

Permalink
feat: simple share fit watchlater and favlist
Browse files Browse the repository at this point in the history
  • Loading branch information
festoney8 committed Jan 2, 2024
1 parent 985bec5 commit dd39551
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## 2.2.2

- 新增:顶栏 稍后再看相关选项
- 新增:评论区规则适配稍后再看页面、收藏夹页面
- 新增:评论区规则、净化分享适配稍后再看页面、收藏夹页面
- 优化:首页 隐藏下载桌面端弹窗 改为默认开启
- 优化:全屏下隐藏弹幕输入框,完整展示章节名
- 优化:用户开启开关时执行功能函数
Expand Down
6 changes: 3 additions & 3 deletions src/pages/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ if (location.host != 'live.bilibili.com') {
headerRightItems.push(
new NormalItem(
'common-hide-nav-favorite',
'隐藏 收藏, 隐藏 稍后再看',
'隐藏 收藏隐藏 稍后再看',
false,
undefined,
false,
Expand All @@ -724,7 +724,7 @@ if (location.host != 'live.bilibili.com') {
headerRightItems.push(
new NormalItem(
'common-hide-nav-favorite-keep-watchlater',
'隐藏 收藏, 保留 稍后再看(实验性)',
'隐藏 收藏,显示 稍后再看(实验性)',
false,
undefined,
false,
Expand All @@ -750,7 +750,7 @@ if (location.host != 'live.bilibili.com') {
headerRightItems.push(
new NormalItem(
'common-nav-keep-watchlater',
'显示 收藏, 显示 稍后再看(实验性)',
'显示 收藏显示 稍后再看(实验性)',
false,
undefined,
false,
Expand Down
26 changes: 18 additions & 8 deletions src/pages/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,26 @@ function simpleShare() {
// 新增click事件
// 若replace element, 会在切换视频后无法更新视频分享数量, 故直接新增click事件覆盖剪贴板
shareBtn.addEventListener('click', () => {
let title = document.querySelector('#viewbox_report > h1')?.textContent as string
let title = document.querySelector('#viewbox_report > h1')?.textContent
if (!title) {
// 尝试稍后再看or收藏夹列表
title = document.querySelector('.video-title-href')?.textContent
if (!title) {
return
}
}
if (
!'(({【[[《「<{〔〖<〈『'.includes(title[0]) &&
!'))}】]]》」>}〕〗>〉』'.includes(title.slice(-1))
) {
title = `【${title}】`
}
let urlPath = location.pathname
if (urlPath.endsWith('/')) {
urlPath = urlPath.slice(0, -1)
}
// 匹配av号, BV号, 分P号
const pattern = /av\d+|BV[1-9A-HJ-NP-Za-km-z]+/g
const avbv = pattern.exec(location.href)
let shareText = `${title} \nhttps://www.bilibili.com/video/${avbv}`
const urlObj = new URL(location.href)
const params = new URLSearchParams(urlObj.search)
let shareText = `${title} \nhttps://www.bilibili.com${urlPath}`
if (params.has('p')) {
shareText += `?p=${params.get('p')}`
}
Expand Down Expand Up @@ -759,7 +765,9 @@ if (
false,
undefined,
false,
`#v_desc {display: none !important;}`,
`#v_desc {display: none !important;}
/* 收藏夹和稍后再看 */
.video-desc-container {display: none !important;}`,
),
)
// 隐藏 tag列表
Expand All @@ -770,7 +778,9 @@ if (
false,
undefined,
false,
`#v_tag {display: none !important;}`,
`#v_tag {display: none !important;}
/* 收藏夹和稍后再看 */
.video-tag-container {display: none !important;}`,
),
)
// 隐藏 活动宣传, 默认开启
Expand Down

0 comments on commit dd39551

Please sign in to comment.