Skip to content

Commit

Permalink
update: live page header rules, url check
Browse files Browse the repository at this point in the history
  • Loading branch information
festoney8 committed Jun 7, 2024
1 parent 352d7a5 commit 342510d
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 36 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.6.5

- 更新:直播页顶栏净化
- 优化:网址判断

## 3.6.4

- 新增:播放页展开完整视频标题
Expand Down
11 changes: 7 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
isPageChannel,
isPageDynamic,
isPageHomepage,
isPageInvalid,
isPagePlaylist,
isPagePopular,
isPageSearch,
Expand Down Expand Up @@ -213,10 +214,12 @@ const main = async () => {
}

try {
log('script start')
await init()
await main()
log('script end')
if (!isPageInvalid()) {
log('script start')
await init()
await main()
log('script end')
}
} catch (err) {
error(err)
}
3 changes: 0 additions & 3 deletions src/rules/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ import {
* 净化掉vd_source参数会导致充电窗口载入失败
*/
const cleanURL = () => {
if (location.href.includes('www.bilibili.com/correspond/')) {
return
}
// 直播域名各种iframe页面(天选、抽奖)和活动页特殊处理
if (location.href.match(/live\.bilibili\.com\/(p\/html|activity|blackboard)/)) {
return
Expand Down
118 changes: 93 additions & 25 deletions src/rules/live.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,104 +497,172 @@ if (isPageLiveHome() || isPageLiveRoom()) {
new CheckboxItem({
itemID: 'live-page-header-entry-logo',
description: '隐藏 直播LOGO',
itemCSS: `#main-ctnr a.entry_logo[href="//live.bilibili.com"] {display: none !important;}`,
itemCSS: `
#main-ctnr a.entry_logo[href="//live.bilibili.com"] {display: none !important;}
.link-navbar-more .search-bar-ctnr {margin: 0 auto !important;}
.pre-hold-nav-logo {display: none !important;}
`,
}),
// 隐藏 首页
new CheckboxItem({
itemID: 'live-page-header-entry-title',
description: '隐藏 首页',
itemCSS: `#main-ctnr a.entry-title[href="//www.bilibili.com"] {display: none !important;}`,
itemCSS: `
#main-ctnr a.entry-title[href="//www.bilibili.com"] {display: none !important;}
.link-navbar-more .search-bar-ctnr {margin: 0 auto !important;}
#prehold-nav-vm .nav-item:has(a[href="//www.bilibili.com"]) {display: none !important;}
`,
}),
// 隐藏 直播
new CheckboxItem({
itemID: 'live-page-header-live',
description: '隐藏 直播',
itemCSS: `#main-ctnr .dp-table-cell a[name="live"] {display: none !important;}`,
itemCSS: `
#main-ctnr .dp-table-cell a[name="live"] {display: none !important;}
.link-navbar-more .search-bar-ctnr {margin: 0 auto !important;}
#prehold-nav-vm .nav-item:has(a[href="//live.bilibili.com"]) {display: none !important;}
`,
}),
// 隐藏 网游
new CheckboxItem({
itemID: 'live-page-header-net-game',
description: '隐藏 网游',
itemCSS: `#main-ctnr .dp-table-cell a[name="网游"] {display: none !important;}`,
itemCSS: `
#main-ctnr .dp-table-cell a[name="网游"] {display: none !important;}
.link-navbar-more .search-bar-ctnr {margin: 0 auto !important;}
#prehold-nav-vm .nav-item:has(a[href*="parentAreaId=2"]) {display: none !important;}
`,
}),
// 隐藏 手游
new CheckboxItem({
itemID: 'live-page-header-mobile-game',
description: '隐藏 手游',
itemCSS: `#main-ctnr .dp-table-cell a[name="手游"] {display: none !important;}`,
itemCSS: `
#main-ctnr .dp-table-cell a[name="手游"] {display: none !important;}
.link-navbar-more .search-bar-ctnr {margin: 0 auto !important;}
#prehold-nav-vm .nav-item:has(a[href*="parentAreaId=3"]) {display: none !important;}
`,
}),
// 隐藏 单机游戏
new CheckboxItem({
itemID: 'live-page-header-standalone-game',
description: '隐藏 单机游戏',
itemCSS: `#main-ctnr .dp-table-cell a[name="单机游戏"] {display: none !important;}`,
itemCSS: `
#main-ctnr .dp-table-cell a[name="单机游戏"] {display: none !important;}
.link-navbar-more .search-bar-ctnr {margin: 0 auto !important;}
#prehold-nav-vm .nav-item:has(a[href*="parentAreaId=6"]) {display: none !important;}
`,
}),
// 隐藏 虚拟主播
new CheckboxItem({
itemID: 'live-page-header-standalone-vtuber',
description: '隐藏 虚拟主播',
itemCSS: `
#main-ctnr .dp-table-cell a[name="虚拟主播"] {display: none !important;}
.link-navbar-more .search-bar-ctnr {margin: 0 auto !important;}
#prehold-nav-vm .nav-item:has(a[href*="parentAreaId=9"]) {display: none !important;}
`,
}),
// 隐藏 娱乐
new CheckboxItem({
itemID: 'live-page-header-standalone-entertainment',
description: '隐藏 娱乐',
itemCSS: `#main-ctnr .dp-table-cell a[name="娱乐"] {display: none !important;}`,
itemCSS: `
#main-ctnr .dp-table-cell a[name="娱乐"] {display: none !important;}
.link-navbar-more .search-bar-ctnr {margin: 0 auto !important;}
#prehold-nav-vm .nav-item:has(a[href*="parentAreaId=1&"]) {display: none !important;}
`,
}),
// 隐藏 电台
new CheckboxItem({
itemID: 'live-page-header-standalone-radio',
description: '隐藏 电台',
itemCSS: `#main-ctnr .dp-table-cell a[name="电台"] {display: none !important;}`,
itemCSS: `
#main-ctnr .dp-table-cell a[name="电台"] {display: none !important;}
.link-navbar-more .search-bar-ctnr {margin: 0 auto !important;}
#prehold-nav-vm .nav-item:has(a[href*="parentAreaId=5"]) {display: none !important;}
`,
}),
// 隐藏 虚拟主播
// 隐藏 赛事
new CheckboxItem({
itemID: 'live-page-header-standalone-vtuber',
description: '隐藏 虚拟主播',
itemCSS: `#main-ctnr .dp-table-cell a[name="虚拟主播"] {display: none !important;}`,
itemID: 'live-page-header-standalone-match',
description: '隐藏 赛事',
itemCSS: `
#main-ctnr .dp-table-cell a[name="赛事"] {display: none !important;}
.link-navbar-more .search-bar-ctnr {margin: 0 auto !important;}
#prehold-nav-vm .nav-item:has(a[href*="parentAreaId=13"]) {display: none !important;}
`,
}),
// 隐藏 聊天室
new CheckboxItem({
itemID: 'live-page-header-standalone-chatroom',
description: '隐藏 聊天室',
itemCSS: `#main-ctnr .dp-table-cell a[name="聊天室"] {display: none !important;}`,
itemCSS: `
#main-ctnr .dp-table-cell a[name="聊天室"] {display: none !important;}
.link-navbar-more .search-bar-ctnr {margin: 0 auto !important;}
#prehold-nav-vm .nav-item:has(a[href*="parentAreaId=14"]) {display: none !important;}
`,
}),
// 隐藏 生活
new CheckboxItem({
itemID: 'live-page-header-standalone-living',
description: '隐藏 生活',
itemCSS: `#main-ctnr .dp-table-cell a[name="生活"] {display: none !important;}`,
itemCSS: `
#main-ctnr .dp-table-cell a[name="生活"] {display: none !important;}
.link-navbar-more .search-bar-ctnr {margin: 0 auto !important;}
#prehold-nav-vm .nav-item:has(a[href*="parentAreaId=10"]) {display: none !important;}
`,
}),
// 隐藏 知识
new CheckboxItem({
itemID: 'live-page-header-standalone-knowledge',
description: '隐藏 知识',
itemCSS: `#main-ctnr .dp-table-cell a[name="知识"] {display: none !important;}`,
}),
// 隐藏 赛事
new CheckboxItem({
itemID: 'live-page-header-standalone-match',
description: '隐藏 赛事',
itemCSS: `#main-ctnr .dp-table-cell a[name="赛事"] {display: none !important;}`,
itemCSS: `
#main-ctnr .dp-table-cell a[name="知识"] {display: none !important;}
.link-navbar-more .search-bar-ctnr {margin: 0 auto !important;}
#prehold-nav-vm .nav-item:has(a[href*="parentAreaId=11"]) {display: none !important;}
`,
}),
// 隐藏 帮我玩
new CheckboxItem({
itemID: 'live-page-header-standalone-helpmeplay',
description: '隐藏 帮我玩',
itemCSS: `#main-ctnr .dp-table-cell a[name="帮我玩"] {display: none !important;}`,
itemCSS: `
#main-ctnr .dp-table-cell a[name="帮我玩"] {display: none !important;}
.link-navbar-more .search-bar-ctnr {margin: 0 auto !important;}
#prehold-nav-vm .nav-item:has(a[href*="parentAreaId=301"]) {display: none !important;}
`,
}),
// 隐藏 互动玩法
new CheckboxItem({
itemID: 'live-page-header-standalone-interact',
description: '隐藏 互动玩法',
itemCSS: `#main-ctnr .dp-table-cell a[name="互动玩法"] {display: none !important;}`,
itemCSS: `
#main-ctnr .dp-table-cell a[name="互动玩法"] {display: none !important;}
.link-navbar-more .search-bar-ctnr {margin: 0 auto !important;}
#prehold-nav-vm .nav-item:has(a[href*="parentAreaId=15"]) {display: none !important;}
`,
}),
// 隐藏 购物
new CheckboxItem({
itemID: 'live-page-header-standalone-shopping',
description: '隐藏 购物',
itemCSS: `#main-ctnr .dp-table-cell a[name="购物"] {display: none !important;}`,
itemCSS: `
#main-ctnr .dp-table-cell a[name="购物"] {display: none !important;}
.link-navbar-more .search-bar-ctnr {margin: 0 auto !important;}
#prehold-nav-vm .nav-item:has(a[href*="parentAreaId=300"]) {display: none !important;}
`,
}),
// 隐藏 更多, 默认开启
new CheckboxItem({
itemID: 'live-page-header-showmore-link',
description: '隐藏 顶栏-更多',
defaultStatus: true,
itemCSS: `#main-ctnr .showmore-link {display: none !important;}`,
itemCSS: `
#main-ctnr .showmore-link {display: none !important;}
.link-navbar-more .search-bar-ctnr {margin: 0 auto !important;}
#prehold-nav-vm .nav-item:last-child {display: none !important;}
`,
}),
]
liveGroupList.push(new Group('live-header-left', '顶栏 左侧', headerLeftItems))
Expand Down
11 changes: 8 additions & 3 deletions src/utils/page-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ const host = location.host
const pathname = location.pathname

const currPage = (): string => {
// 无效url
if (
href.startsWith('https://www.bilibili.com/') &&
['/index.html', '/'].includes(pathname) &&
!pathname.includes('/correspond/')
href.includes('www.bilibili.com/correspond/') ||
href.includes('live.bilibili.com/p/html/') ||
href.includes('live.bilibili.com/live-room-play-game-together')
) {
return 'invalid'
}
if (href.startsWith('https://www.bilibili.com/') && ['/index.html', '/'].includes(pathname)) {
return 'homepage'
}
if (href.includes('bilibili.com/video/')) {
Expand Down Expand Up @@ -62,6 +66,7 @@ const currPage = (): string => {

const ans = currPage()

export const isPageInvalid = () => ans === 'invalid'
export const isPageHomepage = () => ans === 'homepage'
export const isPageVideo = () => ans === 'video'
export const isPagePopular = () => ans === 'popular'
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.6.4',
version: '3.6.5',
description:
'净化 B站/哔哩哔哩 页面,支持「精简功能、播放器净化、过滤视频、过滤评论、全站黑白名单」,提供 300+ 功能,定制自己的 B 站',
author: 'festoney8',
Expand Down

0 comments on commit 342510d

Please sign in to comment.