Skip to content

Commit

Permalink
Merge pull request #88 from festoney8/dev
Browse files Browse the repository at this point in the history
merge dev to main, v3.7.1
  • Loading branch information
festoney8 committed Jun 18, 2024
2 parents ffdc29e + 726bf6f commit 8e94c41
Show file tree
Hide file tree
Showing 18 changed files with 554 additions and 332 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# CHANGELOG

## 3.7.1

- 移除:顶栏右侧稍后再看相关功能,适配网页变动
- 新增:顶栏右侧收藏按钮弹出框,自动选中稍后再看
- 新增:动态页 淡化/隐藏已查看过动态的UP主
- 新增:番剧页 普通播放模式宽度调节
- 新增:播放页 修复/禁用右栏底部吸附
- 修复:播放页 右栏宽度异常
- 优化:重写URL净化、BV号转AV号功能
- 优化:去除播放页网址跳变问题
- 优化:减少URL变化对浏览器历史记录的影响
- 优化:顶栏净化对版权视频页优化

## 3.7.0

- 新增:播放页 播放设定板块
Expand Down
17 changes: 7 additions & 10 deletions src/filters/commentFilter/pages/dynamic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,13 @@ if (isPageDynamic()) {
waitForEle(
document,
'.bili-dyn-home--member, .bili-comment-container, .bili-comment, #app',
(node: Node): boolean => {
if (node instanceof HTMLElement) {
return (
(node as HTMLElement).className === 'bili-dyn-home--member' ||
(node as HTMLElement).className.includes('bili-comment-container') ||
(node as HTMLElement).className.includes('bili-comment') ||
(node as HTMLElement).id === 'app'
)
}
return false
(node: HTMLElement): boolean => {
return (
node.className === 'bili-dyn-home--member' ||
node.className.includes('bili-comment-container') ||
node.className.includes('bili-comment') ||
node.id === 'app'
)
},
).then((ele) => {
if (ele) {
Expand Down
8 changes: 2 additions & 6 deletions src/filters/commentFilter/pages/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,8 @@ if (isPageVideo() || isPageBangumi() || isPagePlaylist()) {
}

try {
waitForEle(document, '#comment, #comment-body, .playlist-comment', (node: Node): boolean => {
return (
node instanceof HTMLElement &&
(['comment', 'comment-body'].includes((node as HTMLElement).id) ||
(node as HTMLElement).className === 'playlist-comment')
)
waitForEle(document, '#comment, #comment-body, .playlist-comment', (node: HTMLElement): boolean => {
return ['comment', 'comment-body'].includes(node.id) || node.className === 'playlist-comment'
}).then((ele) => {
if (ele) {
commentListContainer = ele
Expand Down
4 changes: 2 additions & 2 deletions src/filters/videoFilter/pages/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ if (isPageChannel()) {
}
try {
// 监听视频列表出现
waitForEle(document, 'main.channel-layout', (node: Node): boolean => {
return node instanceof HTMLElement && (node as HTMLElement).className === 'channel-layout'
waitForEle(document, 'main.channel-layout', (node: HTMLElement): boolean => {
return node.className === 'channel-layout'
}).then((ele) => {
if (ele) {
videoListContainer = ele
Expand Down
4 changes: 2 additions & 2 deletions src/filters/videoFilter/pages/homepage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ if (isPageHomepage()) {

try {
// 监听视频列表出现
waitForEle(document, '.container.is-version8', (node: Node): boolean => {
return node instanceof HTMLElement && (node as HTMLElement).className === 'container is-version8'
waitForEle(document, '.container.is-version8', (node: HTMLElement): boolean => {
return node.className === 'container is-version8'
}).then((ele) => {
if (ele) {
videoListContainer = ele
Expand Down
4 changes: 2 additions & 2 deletions src/filters/videoFilter/pages/popular.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,8 @@ if (isPagePopular()) {

try {
// 监听视频列表出现
waitForEle(document, '#app', (node: Node): boolean => {
return node instanceof HTMLElement && (node as HTMLElement).id === 'app'
waitForEle(document, '#app', (node: HTMLElement): boolean => {
return node.id === 'app'
}).then((ele) => {
if (ele) {
videoListContainer = ele
Expand Down
4 changes: 2 additions & 2 deletions src/filters/videoFilter/pages/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ if (isPageSearch()) {

try {
// 监听视频列表出现
waitForEle(document, '.search-content', (node: Node): boolean => {
return node instanceof HTMLElement && (node as HTMLElement).className?.includes('search-content')
waitForEle(document, '.search-content', (node: HTMLElement): boolean => {
return node.className.includes('search-content')
}).then((ele) => {
if (ele) {
videoListContainer = ele
Expand Down
4 changes: 2 additions & 2 deletions src/filters/videoFilter/pages/space.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ if (isPageSpace()) {
}
try {
// 监听视频列表出现
waitForEle(document, '#app', (node: Node): boolean => {
return node instanceof HTMLElement && (node as HTMLElement).id === 'app'
waitForEle(document, '#app', (node: HTMLElement): boolean => {
return node.id === 'app'
}).then((ele) => {
if (ele) {
videoListContainer = ele
Expand Down
8 changes: 2 additions & 6 deletions src/filters/videoFilter/pages/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,8 @@ if (isPageVideo() || isPagePlaylist()) {

try {
// 监听视频列表出现
waitForEle(document, '#reco_list, .recommend-list-container', (node: Node): boolean => {
return (
node instanceof HTMLElement &&
((node as HTMLElement).id === 'reco_list' ||
(node as HTMLElement).className === 'recommend-list-container')
)
waitForEle(document, '#reco_list, .recommend-list-container', (node: HTMLElement): boolean => {
return node.id === 'reco_list' || node.className === 'recommend-list-container'
}).then((ele) => {
if (ele) {
videoListContainer = ele
Expand Down
10 changes: 0 additions & 10 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,6 @@ const main = async () => {
const COMMENT_FILTER_GROUPS = [...videoPageCommentFilterGroupList, ...dynamicPageCommentFilterGroupList]
COMMENT_FILTER_GROUPS.forEach((e) => e.enableGroup())

// 监听各种形式的URL变化 (普通监听无法检测到切换视频)
let lastURL = location.href
setInterval(() => {
const currURL = location.href
if (currURL !== lastURL) {
RULE_GROUPS.forEach((e) => e.reloadGroup())
lastURL = currURL
}
}, 500)

// 全局启动/关闭快捷键 chrome: Alt+B,firefox: Ctrl+Alt+B
let isGroupEnable = true
document.addEventListener('keydown', (event) => {
Expand Down
58 changes: 48 additions & 10 deletions src/rules/bangumi.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { GM_getValue, GM_setValue } from '$'
import { Group } from '../components/group'
import { CheckboxItem } from '../components/item'
import { CheckboxItem, NumberItem } from '../components/item'
import { error } from '../utils/logger'
import { isPageBangumi } from '../utils/page-type'
import { waitForEle } from '../utils/tool'

const bangumiGroupList: Group[] = []

Expand Down Expand Up @@ -59,44 +60,81 @@ if (isPageBangumi()) {
description: '顶栏 滚动页面后不再吸附顶部',
itemCSS: `.fixed-header .bili-header__bar {position: relative !important;}`,
}),
]
bangumiGroupList.push(new Group('bangumi-basic', '版权视频播放页 基本功能', basicItems))

// 播放设定
const playerInitItems = [
// 网页全屏时 页面可滚动
new CheckboxItem({
itemID: 'webscreen-scrollable',
description: '网页全屏时 页面可滚动 滚轮调音量失效\n(Firefox 不适用)',
itemCSS: `
body:has(#bilibili-player-wrap[class^='video_playerFullScreen']) {
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 {
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 {
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 {
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 {
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']) {
:is(html, body):has(#bilibili-player-wrap[class*='video_playerFullScreen']) {
scrollbar-width: none !important;
}
}
`,
// 在Chrome上可以神奇的禁用滚轮调节音量,Firefox不生效
itemFunc: () => document.addEventListener('wheel', disableAdjustVolume),
itemFunc: () => {
// 在Chrome上可以神奇的禁用滚轮调节音量,Firefox不生效
document.addEventListener('wheel', disableAdjustVolume)
// 监听网页全屏按钮出现
const listener = () => {
waitForEle(document.body, '.bpx-player-ctrl-web', (node: HTMLElement): boolean => {
return node.className.includes('bpx-player-ctrl-web')
}).then((webBtn) => {
if (webBtn) {
webBtn.addEventListener('click', () => {
if (webBtn.classList.contains('bpx-state-entered')) {
window.scrollTo(0, 0)
}
})
}
})
}
document.readyState === 'complete'
? listener()
: document.addEventListener('DOMContentLoaded', listener)
},
callback: () => document.removeEventListener('wheel', disableAdjustVolume),
}),
// 普通播放 视频宽度调节
new NumberItem({
itemID: 'normalscreen-width',
description: '普通播放 视频宽度调节(-1禁用)',
defaultValue: -1,
minValue: -1,
maxValue: 100,
disableValue: -1,
unit: 'vw',
// 官方样式写的棒真是太好了
itemCSS: `.home-container:not(.wide) {--video-width: ???vw;}`,
itemCSSPlaceholder: '???',
}),
]
bangumiGroupList.push(new Group('bangumi-basic', '版权视频播放页 基本功能', basicItems))
bangumiGroupList.push(new Group('player-mode', '播放设定(实验功能)', playerInitItems))

// 播放器
const playerItems = [
Expand Down
Loading

0 comments on commit 8e94c41

Please sign in to comment.