Skip to content

Commit

Permalink
Merge pull request #29 from festoney8/dev
Browse files Browse the repository at this point in the history
merge dev to main, v3.1.1
  • Loading branch information
festoney8 authored Feb 1, 2024
2 parents 9bd7ef4 + 5eaa415 commit 8b75f27
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CHANGELOG

## 3.1.1

- 新增:播放页 隐藏播放器视频播放效果调查
- 修复:BV号转AV号可能的溢出问题

## 3.1.0

- 新增:视频过滤支持搜索页
Expand Down
4 changes: 4 additions & 0 deletions src/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@ export declare global {
isWide?: boolean
hasBlackSide?: boolean
setSize?: function
vd?: {
aid?: number
bvid?: string
}
}
}
19 changes: 17 additions & 2 deletions src/rules/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { isPagePlaylist, isPageVideo } from '../utils/page-type'
/** BV号转AV号 */
const bv2av = () => {
/**
* 可能会出现转换后av号带短横的bug(溢出),作为后备方案
* bv2av algo by mcfx
* @see https://www.zhihu.com/question/381784377/answer/1099438784
* @param x 输入BV号
Expand All @@ -25,7 +26,14 @@ const bv2av = () => {
for (let i = 0; i < 6; i++) {
r += tr[x[s[i]]] * 58 ** i
}
return (r - add) ^ xor
// 修复一下溢出
const aid = (r - add) ^ xor
return aid > 0 ? aid : aid + 2147483648
}

// 从window对象获取avid
const getAid = (): number | undefined => {
return window.vd?.aid
}

if (location.href.includes('bilibili.com/video/BV')) {
Expand All @@ -37,7 +45,7 @@ const bv2av = () => {
if (params.has('p')) {
partNum += `?p=${params.get('p')}`
}
const aid = dec(bvid)
const aid = getAid() ?? dec(bvid)
const newURL = `https://www.bilibili.com/video/av${aid}${partNum}${location.hash}`
history.replaceState(null, '', newURL)
debug('bv2av complete')
Expand Down Expand Up @@ -281,6 +289,13 @@ if (isPageVideo() || isPagePlaylist()) {
description: '隐藏 投票弹窗',
itemCSS: `.bpx-player-video-area .bili-vote, .bpx-player-video-area .bili-cmd-shrink {display: none !important;}`,
}),
// 隐藏 播放效果调查, 默认开启
new CheckboxItem({
itemID: 'video-page-hide-bpx-player-bili-qoe-feedback',
description: '隐藏 播放效果调查',
defaultStatus: true,
itemCSS: `.bpx-player-video-area .bili-qoeFeedback {display: none !important;}`,
}),
// 隐藏 评分弹窗
new CheckboxItem({
itemID: 'video-page-hide-bpx-player-bili-score',
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.1.0',
version: '3.1.1',
description:
'净化 B站/哔哩哔哩 网页元素,去广告,URL净化,BV号转AV号,播放器净化,过滤推荐视频,提供300+项功能,定制自己的B站页面',
author: 'festoney8',
Expand Down

0 comments on commit 8b75f27

Please sign in to comment.