Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge dev to main, v3.7.0 #85

Merged
merged 22 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# CHANGELOG

## 3.7.0

- 新增:播放页 播放设定板块
- 新增:默认宽屏播放
- 新增:网页全屏时页面可滚动
- 新增:普通播放模式宽度调节
- 新增:动态页隐藏整个评论区
- 新增:顶栏屏蔽BML
- 更新:直播页顶栏净化
- 优化:网址判断
- 优化:功能细节

## 3.6.4

- 新增:播放页展开完整视频标题
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,7 @@
### 2. 与 [bilibili-app-recommend](https://greasyfork.org/zh-CN/scripts/443530) 的兼容性

- **兼容**,提供 **隐藏 视频tag / 隐藏 弹幕数 / 隐藏 点赞数** 功能,在首页功能菜单末尾
- bilibili-app-recommend 自带 UP 主黑名单,无需使用本插件的视频过滤
- 标题关键词过滤、BV 号过滤暂不支持该插件的推荐列表
- bilibili-app-recommend 自带 UP 主黑名单、标题关键词过滤,在首页无需使用本插件的过滤功能

### 3. 与 [Bilibili 旧播放页](https://github.com/MotooriKashin/Bilibili-Old) 的兼容性

Expand Down
11 changes: 7 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
isPageChannel,
isPageDynamic,
isPageHomepage,
isPageInvalid,
isPagePlaylist,
isPagePopular,
isPageSearch,
Expand Down Expand Up @@ -213,10 +214,12 @@ const main = async () => {
}

try {
log('script start')
await init()
await main()
log('script end')
if (!isPageInvalid()) {
log('script start')
await init()
await main()
log('script end')
}
} catch (err) {
error(err)
}
165 changes: 98 additions & 67 deletions src/rules/bangumi.ts
Original file line number Diff line number Diff line change
@@ -1,70 +1,12 @@
import { GM_getValue, GM_setValue } from '$'
import { Group } from '../components/group'
import { CheckboxItem } from '../components/item'
import { debugRules as debug, error } from '../utils/logger'
import { error } from '../utils/logger'
import { isPageBangumi } from '../utils/page-type'

const bangumiGroupList: Group[] = []

/** 覆盖版权视频页分享按钮功能 (疑似firefox在bangumi page覆盖失败) */
let isBangumiSimpleShareBtn = false
const bangumiSimpleShare = () => {
if (isBangumiSimpleShareBtn) {
return
}
// 监听shareBtn出现
let shareBtn
let counter = 0
const checkElement = setInterval(() => {
counter++
shareBtn = document.getElementById('share-container-id')
if (shareBtn) {
isBangumiSimpleShareBtn = true
clearInterval(checkElement)
// 新增click事件覆盖剪贴板
shareBtn.addEventListener('click', () => {
const mainTitle = document.querySelector("[class^='mediainfo_mediaTitle']")?.textContent
const subTitle = document.getElementById('player-title')?.textContent
const shareText = `《${mainTitle}》${subTitle} \nhttps://www.bilibili.com${location.pathname}`
navigator.clipboard.writeText(shareText)
})
debug('bangumiSimpleShare complete')
} else if (counter > 50) {
clearInterval(checkElement)
debug('bangumiSimpleShare timeout')
}
}, 200)
}

/** 投币时取消自动点赞 */
const coinDisableAutoLike = () => {
const disableAutoLike = () => {
let counter = 0
const timer = setInterval(() => {
const checkbox = document.querySelector(
'.main-container [class^="dialogcoin_like_checkbox"] input',
) as HTMLInputElement
if (checkbox) {
checkbox.checked && checkbox.click()
clearInterval(timer)
} else {
counter++
if (counter > 100) {
clearInterval(timer)
}
}
}, 20)
}
const coinBtn = document.querySelector('#ogv_weslie_tool_coin_info') as HTMLElement | null
if (coinBtn) {
coinBtn.addEventListener('click', disableAutoLike)
} else {
document.addEventListener('DOMContentLoaded', () => {
const coinBtn = document.querySelector('#ogv_weslie_tool_coin_info') as HTMLElement | null
coinBtn?.addEventListener('click', disableAutoLike)
})
}
}
const disableAdjustVolume = () => {}

/**
* 版权视频播放页规则
Expand All @@ -79,18 +21,80 @@ if (isPageBangumi()) {
itemID: 'video-page-simple-share',
description: '净化分享功能',
defaultStatus: true,
itemFunc: bangumiSimpleShare,
itemCSS: `#share-container-id [class^='Share_boxBottom'] {display: none !important;}
#share-container-id [class^='Share_boxTop'] {padding: 15px !important;}
#share-container-id [class^='Share_boxTopRight'] {display: none !important;}
#share-container-id [class^='Share_boxTopLeft'] {padding: 0 !important;}`,
itemCSS: `
#share-container-id [class^='Share_boxBottom'] {display: none !important;}
#share-container-id [class^='Share_boxTop'] {padding: 15px !important;}
#share-container-id [class^='Share_boxTopRight'] {display: none !important;}
#share-container-id [class^='Share_boxTopLeft'] {padding: 0 !important;}
`,
itemFunc: () => {
// 监听shareBtn出现
const listener = () => {
let counter = 0
const id = setInterval(() => {
counter++
const shareBtn = document.getElementById('share-container-id')
if (shareBtn) {
clearInterval(id)
// 新增click事件覆盖剪贴板
shareBtn.addEventListener('click', () => {
const mainTitle = document.querySelector("[class^='mediainfo_mediaTitle']")?.textContent
const subTitle = document.getElementById('player-title')?.textContent
const shareText = `《${mainTitle}》${subTitle} \nhttps://www.bilibili.com${location.pathname}`
navigator.clipboard.writeText(shareText)
})
} else if (counter > 50) {
clearInterval(id)
}
}, 200)
}
document.readyState === 'complete'
? listener()
: document.addEventListener('DOMContentLoaded', listener)
},
}),
// 顶栏 滚动页面后不再吸附顶部
new CheckboxItem({
itemID: 'video-page-hide-fixed-header',
description: '顶栏 滚动页面后不再吸附顶部',
itemCSS: `.fixed-header .bili-header__bar {position: relative !important;}`,
}),
// 网页全屏时 页面可滚动
new CheckboxItem({
itemID: 'webscreen-scrollable',
description: '网页全屏时 页面可滚动 滚轮调音量失效\n(Firefox 不适用)',
itemCSS: `
body:has(#bilibili-player-wrap[class^='video_playerFullScreen']) {
overflow: auto !important;
position: relative !important;
}
body:has(#bilibili-player-wrap[class^='video_playerFullScreen']) #bilibili-player-wrap {
position: absolute !important;
width: 100vw !important;
height: 100vh !important;
}
body:has(#bilibili-player-wrap[class^='video_playerFullScreen']) .main-container {
position: static !important;
margin: 0 auto !important;
padding-top: calc(100vh + 15px) !important;
}
body:has(#bilibili-player-wrap[class^='video_playerFullScreen']) .bpx-player-video-area {
flex: unset !important;
}
body:has(#bilibili-player-wrap[class^='video_playerFullScreen'])::-webkit-scrollbar {
display: none !important;
}
/* firefox */
@-moz-document url-prefix() {
:is(html, body):has(#bilibili-player-wrap[class^='video_playerFullScreen']) {
scrollbar-width: none !important;
}
}
`,
// 在Chrome上可以神奇的禁用滚轮调节音量,Firefox不生效
itemFunc: () => document.addEventListener('wheel', disableAdjustVolume),
callback: () => document.removeEventListener('wheel', disableAdjustVolume),
}),
]
bangumiGroupList.push(new Group('bangumi-basic', '版权视频播放页 基本功能', basicItems))

Expand Down Expand Up @@ -465,7 +469,34 @@ if (isPageBangumi()) {
new CheckboxItem({
itemID: 'video-page-coin-disable-auto-like',
description: '投币时不自动点赞 (关闭需刷新)',
itemFunc: coinDisableAutoLike,
itemFunc: () => {
const disableAutoLike = () => {
let counter = 0
const timer = setInterval(() => {
const checkbox = document.querySelector(
'.main-container [class^="dialogcoin_like_checkbox"] input',
) as HTMLInputElement
if (checkbox) {
checkbox.checked && checkbox.click()
clearInterval(timer)
} else {
counter++
if (counter > 100) {
clearInterval(timer)
}
}
}, 20)
}
const coinBtn = document.querySelector('#ogv_weslie_tool_coin_info') as HTMLElement | null
if (coinBtn) {
coinBtn.addEventListener('click', disableAutoLike)
} else {
document.addEventListener('DOMContentLoaded', () => {
const coinBtn = document.querySelector('#ogv_weslie_tool_coin_info') as HTMLElement | null
coinBtn?.addEventListener('click', disableAutoLike)
})
}
},
}),
// 隐藏 分享按钮弹出菜单, 默认开启
new CheckboxItem({
Expand Down Expand Up @@ -523,7 +554,7 @@ if (isPageBangumi()) {
itemID: 'bangumi-page-hide-right-container-section-height',
description: '隐藏 大会员按钮 ★',
defaultStatus: true,
itemCSS: `[class^='vipPaybar_'] {display: none !important;}`,
itemCSS: `.plp-r [class^='vipPaybar_'], .plp-r [class^='paybar_'] {display: none !important;}`,
}),
// 隐藏 弹幕列表, 默认开启
new CheckboxItem({
Expand Down
Loading