Skip to content

Commit

Permalink
optimize: panel display remember position
Browse files Browse the repository at this point in the history
  • Loading branch information
festoney8 committed Jan 4, 2024
1 parent 897a90d commit 98f6189
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 2.2.3

- 优化:panel显示方式,同一页面内再次打开panel记录上次位置

## 2.2.2

- 新增:顶栏 稍后再看相关选项
Expand Down
3 changes: 2 additions & 1 deletion src/core/panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ export class Panel implements IPanel {
const panel = document.getElementById('bili-cleaner') as HTMLFormElement
const closeBtn = document.getElementById('bili-cleaner-close') as HTMLFormElement
closeBtn.addEventListener('click', () => {
panel.remove()
// 使用 display:none 代替 remove(), 同一页面内再次打开panel记录上次位置
panel.style.display = 'none'
})
debug('watchCloseBtn OK')
} catch (err) {
Expand Down
9 changes: 6 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,15 @@ const main = async () => {

// 注册油猴插件菜单
const openSettings = () => {
if (document.getElementById('bili-cleaner')) {
const panel = document.getElementById('bili-cleaner') as HTMLFormElement
if (panel) {
// 再次打开panel, 显示上次位置
panel.style.removeProperty('display')
return
}
debug('panel create start')
const panel = new Panel()
panel.createPanel()
const newPanel = new Panel()
newPanel.createPanel()
GROUPS.forEach((e) => {
e.insertGroup()
e.insertGroupItems()
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: '2.2.2',
version: '2.2.3',
description:
'净化 B站/哔哩哔哩 页面内各种元素,去广告,BV号转AV号,净化播放器,提供300+项功能,定制自己的B站页面',
author: 'festoney8',
Expand Down

0 comments on commit 98f6189

Please sign in to comment.