Skip to content

Commit

Permalink
feat: 添加大会员彩色屏蔽功能。#151
Browse files Browse the repository at this point in the history
  • Loading branch information
msojocs committed Feb 1, 2025
1 parent d717711 commit b6bc072
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 153 deletions.
8 changes: 0 additions & 8 deletions .idea/.gitignore

This file was deleted.

13 changes: 0 additions & 13 deletions .idea/bilibili-linux.iml

This file was deleted.

5 changes: 0 additions & 5 deletions .idea/codeStyles/codeStyleConfig.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

7 changes: 7 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# 🌈 v1.16.2-3 / 2025-02-01

## 🚀 功能

- 弹幕:添加大会员彩色屏蔽功能。
- 弹幕:更改等级屏蔽设置入口与生效逻辑。

# 🌈 v1.16.2-2 / 2025-01-15

## 🐞 修复
Expand Down
12 changes: 10 additions & 2 deletions extensions/area_unlimit/hook/PlayerEnhance.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<link rel="stylesheet" href="https://lib.baomitu.com/element-plus/2.2.0/index.min.css">
</div>
<div id="player-settings-ext">
<el-dialog v-model="settingsVisible" title="弹幕填充" width="60%">
<el-dialog v-model="settingsVisible" title="弹幕拓展功能" width="60%">
<el-tabs
v-model="activeName"
type="card"
Expand All @@ -13,8 +13,16 @@
</el-tab-pane>
<el-tab-pane label="弹弹Play" name="dandanplay">
</el-tab-pane>
<el-tab-pane label="弹幕设定" name="danmu-settings">
<div style="display: flex;width: 500px;justify-content: center;align-items: center;">
<span style="width: 20%;">屏蔽等级:</span>
<el-slider v-model="blockLevel" :step="1" :max="10" show-stops />
</div>
<br>
<el-checkbox v-model="isBlockVipColor" label="屏蔽大会员彩色弹幕" size="large" />
</el-tab-pane>
</el-tabs>
<div>
<div v-if="activeName === 'bilibili' || activeName === 'dandanplay'">
<el-row>
<el-col :span="4" class="flex_center">搜索:</el-col>
<el-col :span="19">
Expand Down
147 changes: 36 additions & 111 deletions extensions/area_unlimit/hook/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ const sleep = (ms) => {
// danmakuManage.danmakuStore.loadDmPbAll(true)

return Promise.resolve(`成功加载${comments.length}条弹幕`)
}
},
}
const UI = (()=>{
const init = ()=>{
Expand Down Expand Up @@ -281,6 +281,9 @@ const sleep = (ms) => {
dmTimelineDrawer: false,
moveFactor: 0,
dandanplayWithRelated: true,
// block level 屏蔽等级
blockLevel: 0,
isBlockVipColor: false,
};
},
created() {
Expand All @@ -293,6 +296,9 @@ const sleep = (ms) => {
UI.dmTimeline = ()=>{
this.dmTimelineDrawer = !this.dmTimelineDrawer
}
this.blockLevel = parseInt(localStorage.getItem('dm-filter-weight') || '0')
log.info('current weight:', this.weight)
this.isBlockVipColor = localStorage.getItem('dm-filter-blockvip') === 'true'
},
methods: {
doSearch: function(){
Expand All @@ -313,7 +319,7 @@ const sleep = (ms) => {
default:
break;
}
HandleResult[this.activeName](this.selectOptions, data)
HandleResult[this.activeName]?.(this.selectOptions, data)
.then(res=>{
this.$message({
message: res,
Expand Down Expand Up @@ -347,6 +353,14 @@ const sleep = (ms) => {
dm.stime += time
});
}
},
watch: {
blockLevel(n, o) {
localStorage.setItem('dm-filter-weight', n)
},
isBlockVipColor(n, o) {
localStorage.setItem('dm-filter-blockvip', n)
},
}
};
const app = Vue.createApp(App);
Expand Down Expand Up @@ -416,131 +430,42 @@ const sleep = (ms) => {
speedRate.before(createElement(3.0))
speedRate.before(createElement(2.5))
{
/**
* @type {Element | null}
*/
const speed = window.danmakuManage.nodes.controlBottomCenter.querySelector('.bpx-player-dm-setting-left-speedplus')

const weightFilter = document.createElement('div')
weightFilter.innerHTML = `
<div class="bpx-player-dm-setting-left-speedplus bui bui-progress">
<div class="bpx-player-dm-setting-left-speedplus-title">屏蔽等级</div>
<div class="bpx-player-dm-setting-left-speedplus-content">
<div class="bpx-player-dm-setting-ui-speedplus"></div>
</div>
<div class="bui-area">
<div class="bui-progress-wrap">
<div class="bui-progress-bar" style="width: 0%;">
<span class="bui-progress-dot"></span>
</div>
<div class="bui-progress-step">
<div class="bui-progress-item" style="left:0%">
<div class="bui-progress-lab"></div>
</div>
</div>
</div>
<div class="bui-progress-val" style="width:60px">0</div>
</div>
</div>`
const valueText = weightFilter.querySelector('.bui-progress-val')
const value = weightFilter.querySelector('.bui-progress-bar')
const option = weightFilter.querySelector('.bui-progress-item')
let originalFilter = window.danmakuManage.danmaku.config.fn.filter
const changeFilterWeight = (weight) => {
if (weight > 10) weight = 10
if (weight < 0) weight = 0
localStorage.setItem('dm-filter-weight', weight)

valueText.textContent = `${weight}级`
value.style.width = `${weight * 10}%`
if (weight < 5)
{
value.firstElementChild.style.transform = 'translate3d(10px, -4px, 0px)'
}
else {
value.firstElementChild.style = {}
const customFilter = (t) => {
log.info('filter....')
if (originalFilter(t)){
// log.info('default block:', t.weight)
return true
}

window.danmakuManage.danmaku.config.fn.filter = (t) => {
// log.info('filter:', t)
if (originalFilter(t)){
// log.info('default block:', t.weight)
return true
}
if (t.weight < weight) {
// log.info('block weight:', t.weight)
if (localStorage.getItem('dm-filter-blockvip') === 'true')
{
// 屏蔽大会员彩色
if (t.colorful || t.colorfulImg) {
log.info('block vip', JSON.stringify(t, null, 4))
return true
}
return false

}
const weight = parseInt(localStorage.getItem('dm-filter-weight') || '0')
if (t.weight <= weight) {
log.info('current weight:', weight)
log.info('block weight:', JSON.stringify(t, null, 4))
return true
}
return false
}
let isDown = false
const cal = (e) => {
// log.info('click options', e)
if (e.target.classList.contains('bui-progress-dot')) return
const filterWeight = Math.round(e.offsetX / 160 * 10)
// log.info('click result:', e.offsetX, filterWeight)

changeFilterWeight(filterWeight)
}
option.parentElement.parentElement.onmousedown = (e) => {
isDown = true
cal(e)
}
option.parentElement.parentElement.onmouseup = () => {
isDown = false
}
option.parentElement.parentElement.onmousemove = (e) => {
if (isDown) cal(e)
}
window.danmakuManage.danmaku.config.fn.filter = customFilter
{
const originalInitDanmaku = window.danmakuManage.initDanmaku
window.danmakuManage.initDanmaku = function () {
log.info('initDanmaku...')
originalInitDanmaku.apply(this)
log.info('update filter...')
originalFilter = this.danmaku.config.fn.filter
changeFilterWeight(parseInt(localStorage.getItem('dm-filter-weight') || '0'))
{
let check = setInterval(() => {
/**
调整大小
* @type {Element | null}
*/
const left = document.querySelector('.bpx-player-dm-setting-left')
if (left.parentElement.style.height === '340px')
clearInterval(check)
left.parentElement.style.height = '340px'
left.parentElement.parentElement.parentElement.style.height = '340px'
log.info('fix height end')
}, 1000)
}
window.danmakuManage.danmaku.config.fn.filter = customFilter
}
}
changeFilterWeight(parseInt(localStorage.getItem('dm-filter-weight') || '0'))

for (let i = 0; i <= 10; i++) {
const newOption = option.cloneNode(true)
newOption.style.left = `${i * 10}%`
option.before(newOption)
}
option.remove()
// log.info(weightFilter.firstElementChild)
speed.after(weightFilter.firstElementChild)
{
let check = setInterval(() => {
/**
调整大小
* @type {Element | null}
*/
const left = document.querySelector('.bpx-player-dm-setting-left')
if (left.parentElement.style.height === '340px')
clearInterval(check)
left.parentElement.style.height = '340px'
left.parentElement.parentElement.parentElement.style.height = '340px'
log.info('fix height end')
}, 1000)
}
}
clearInterval(rate175check)
}catch(err){
Expand Down
3 changes: 3 additions & 0 deletions tools/setup-bilibili
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ notice() {

res_dir="$root_dir/tmp/bili/resources"

cd $root_dir
pnpm install

"$root_dir/tools/update-electron"
"$root_dir/tools/update-bilibili"
"$root_dir/tools/fix-other.sh"
Expand Down

0 comments on commit b6bc072

Please sign in to comment.