Skip to content

Commit

Permalink
update: limit drag bar position
Browse files Browse the repository at this point in the history
  • Loading branch information
festoney8 committed Mar 11, 2024
1 parent 552fb78 commit b6fde80
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

## 3.1.11

- 修复:尝试修复直播间天选时刻蒙版bug
- 修复:修复直播页天选时刻蒙版bug
- 新增:隐藏直播页天选时刻
- 优化:限制panel可拖拽范围在视口内

## 3.1.10

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
- 适用于 **净化新版 bilibili 网页**,不做老版本页面适配
- 混搭各种功能,调节浏览器缩放比例,可调节出自己满意的页面效果
- 默认用户已登录,默认开启基础屏蔽功能,大会员体验最佳
- 已知bug:支持切换视角的直播和特殊活动直播,调节净化规则无法实时生效,需刷新页面
- 已知bug:支持切换视角的直播、特殊活动直播,调节脚本设置后需刷新页面才生效,弹幕净化不生效

> [!NOTE]
>
Expand Down
14 changes: 14 additions & 0 deletions src/components/panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,20 @@ class Panel {
const diffY = e.clientY - initY
panel.style.left = `${initLeft + diffX}px`
panel.style.top = `${initTop + diffY}px`
// 限制bar不超出视口
const rect = bar.getBoundingClientRect()
if (rect.left < 0) {
panel.style.left = `${initLeft + diffX - rect.left}px`
}
if (rect.top < 0) {
panel.style.top = `${initTop + diffY - rect.top}px`
}
if (rect.right > window.innerWidth) {
panel.style.left = `${initLeft + diffX - (rect.right - window.innerWidth)}px`
}
if (rect.bottom > window.innerHeight) {
panel.style.top = `${initTop + diffY - (rect.bottom - window.innerHeight)}px`
}
}
})
document.addEventListener('mouseup', () => {
Expand Down
4 changes: 4 additions & 0 deletions src/rules/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ import {
* 净化掉vd_source参数会导致充电窗口载入失败
*/
const cleanURL = () => {
// 直播页只净化直播间
if (location.host === 'live.bilibili.com' && !isPageLiveRoom()) {
return
}
// 天选时刻iframe特殊处理
if (location.href.includes('live-lottery')) {
return
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.10',
version: '3.1.11',
description:
'净化 B站/哔哩哔哩 网页元素,去广告,URL净化,BV号转AV号,播放器净化,过滤推荐视频,提供300+项功能,定制自己的B站页面',
author: 'festoney8',
Expand Down

0 comments on commit b6fde80

Please sign in to comment.