Skip to content

Commit

Permalink
Merge pull request #119 from festoney8/dev
Browse files Browse the repository at this point in the history
merge dev to main, v3.10.3
  • Loading branch information
festoney8 authored Aug 7, 2024
2 parents 9a7767a + f442f27 commit 1b0a0a9
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 44 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# CHANGELOG

## 3.10.3

- 新增:番剧播放页 默认宽屏播放
- 修复:分区排行榜视频过滤
- 修复:小窗播放器 记录位置

## 3.10.2

- 新增:空间页 用户主页自动跳转到投稿
Expand Down
5 changes: 2 additions & 3 deletions src/filters/video/popular.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ if (isPagePopular()) {
fetchHook.addPostFn((input: RequestInfo | URL, init: RequestInit | undefined, resp?: Response) => {
if (
typeof input === 'string' &&
input.includes('api.bilibili.com') &&
input.match(/web-interface\/(ranking|popular\/series\/one|popular\?ps)/) &&
/api\.bilibili\.com.+web-interface\/(ranking|popular\/series\/one|popular\?ps)/.test(input) &&
init?.method?.toUpperCase() === 'GET' &&
resp
) {
Expand Down Expand Up @@ -228,7 +227,7 @@ if (isPagePopular()) {
: `.video-list .video-card:not([${settings.filterSign}])`
}
// 排行榜
if (location.pathname.includes('/v/popular/rank/all')) {
if (location.pathname.includes('/v/popular/rank')) {
selector = fullSite ? `.rank-list .rank-item` : `.rank-list .rank-item:not([${settings.filterSign}])`
}

Expand Down
1 change: 1 addition & 0 deletions src/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export declare global {
comment_next_version?: 'ELEMENTS' | 'DEFAULT'
}
}
__NEXT_DATA__?: any
EmbedPlayer?: {
instance?: {
getPlayerInfo: () => {
Expand Down
22 changes: 22 additions & 0 deletions src/rules/bangumi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,28 @@ if (isPageBangumi()) {

// 播放设定
const playerInitItems = [
// 默认宽屏播放
new CheckboxItem({
itemID: 'default-widescreen',
description: '默认宽屏播放 刷新生效',
enableFunc: () => {
let origNextData = unsafeWindow.__NEXT_DATA__
if (origNextData?.props?.pageProps?.dehydratedState?.queries?.[1]?.state?.data?.show) {
origNextData.props.pageProps.dehydratedState.queries[1].state.data.show.wide_screen = 1
}
Object.defineProperty(unsafeWindow, '__NEXT_DATA__', {
get() {
return origNextData
},
set(value) {
if (value.props?.pageProps?.dehydratedState?.queries?.[1]?.state?.data?.show) {
value.props.pageProps.dehydratedState.queries[1].state.data.show.wide_screen = 1
}
origNextData = value
},
})
},
}),
// 网页全屏时 页面可滚动
new CheckboxItem({
itemID: 'webscreen-scrollable',
Expand Down
65 changes: 25 additions & 40 deletions src/rules/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -931,50 +931,35 @@ if (isPageVideo() || isPagePlaylist() || isPageFestival()) {
itemID: 'video-page-bpx-player-mini-mode-position-record',
description: '记录小窗位置',
enableFunc: async () => {
let player: HTMLElement

// 监听mini播放器移动
const addMiniPlayerMoveListener = () => {
if (!player) {
return
}
player.addEventListener('mouseup', () => {
if (player.getAttribute('data-screen') !== 'mini') {
return
}
GM_setValue(
'BILICLEANER_video-page-bpx-player-mini-mode-position-record-right',
parseInt(player.style.right),
)
GM_setValue(
'BILICLEANER_video-page-bpx-player-mini-mode-position-record-bottom',
parseInt(player.style.bottom),
)
})
const keys = {
tx: 'BILICLEANER_video-page-bpx-player-mini-mode-position-record-translate-x',
ty: 'BILICLEANER_video-page-bpx-player-mini-mode-position-record-translate-y',
}
// 设置player API内小窗播放器position初始值
const setMiniPlayerState = () => {
const right = GM_getValue('BILICLEANER_video-page-bpx-player-mini-mode-position-record-right')
const bottom = GM_getValue('BILICLEANER_video-page-bpx-player-mini-mode-position-record-bottom')
if (typeof right === 'number' && typeof bottom === 'number') {
if (unsafeWindow.player) {
unsafeWindow.player.__core().uiStore.state.miniScreenRight = right
unsafeWindow.player.__core().uiStore.state.miniScreenBottom = bottom
}
}

// 注入样式
const x = GM_getValue(keys.tx, 0)
const y = GM_getValue(keys.ty, 0)
if (x && y) {
const s = document.createElement('style')
s.innerHTML = `.bpx-player-container[data-screen="mini"] {transform: translateX(${x}px) translateY(${y}px);}`
s.setAttribute('bili-cleaner-css', 'video-page-bpx-player-mini-mode-position-record')
document.documentElement.appendChild(s)
}

waitForEle(document.body, '#bilibili-player .bpx-player-container', (node: HTMLElement) => {
waitForEle(document, '#bilibili-player .bpx-player-container', (node: HTMLElement) => {
return node.className.startsWith('bpx-player-container')
}).then((ele) => {
if (ele) {
player = ele
try {
setMiniPlayerState()
addMiniPlayerMoveListener()
} catch {
// err
}
}).then((player) => {
if (player) {
// 监听mini播放器移动
player.addEventListener('mouseup', () => {
if (player.getAttribute('data-screen') === 'mini') {
const rect = player.getBoundingClientRect()
const dx = document.documentElement.clientWidth - rect.right
const dy = document.documentElement.clientHeight - rect.bottom
GM_setValue(keys.tx, 84 - dx)
GM_setValue(keys.ty, 48 - dy)
}
})
}
})
},
Expand Down
2 changes: 1 addition & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default defineConfig({
userscript: {
name: 'bilibili 页面净化大师',
namespace: 'http://tampermonkey.net/',
version: '3.10.2',
version: '3.10.3',
description:
'净化 B站/哔哩哔哩 页面,支持「精简功能、播放器净化、过滤视频、过滤评论、全站黑白名单」,提供 300+ 功能,定制自己的 B 站',
author: 'festoney8',
Expand Down

0 comments on commit 1b0a0a9

Please sign in to comment.