0%

b站首页净化脚本

b 站首页实在太多辣鸡推广, 而本人一般只看关注的阿婆主的视频, 故做出此油猴脚本屏蔽掉不要的内容.

脚本地址

脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// ==UserScript==
// @name Pure bilibili
// @namespace https://www.bilibili.com/
// @version 0.1
// @description Offer a pure bilibili home page
// @author You
// @match https://www.bilibili.com/
// @grant none
// ==/UserScript==
(function() {
const search_box_holder = 'ricercare videi'
const right_font_style = 'color: #000; white-space: nowrap; text-shadow: none'
delete_dom_by_className(['b-wrap', 'international-footer', 'bili-banner', 'contact-help', 'nav-link'])

window.addEventListener('load', function(){
delete_dom_by_className(['nav-search-btn', 'search-icon'])
beauty_dom_by_id([
{
'name': 'app',
'style': 'height: 100%'
}
])
beauty_dom_by_className([
{
'name': 'name',
'style': right_font_style
},{
'name': 'mini-header',
'style': 'position: relative; z-index: 1; width: 100%; height: 100%;'
},{
'name': 'mini-header__content',
'style': 'flex-direction: column-reverse; height: 100%'
},{
'name': 'international-home',
'style': 'height: 100%'
},{
'name': 'international-header',
'style': 'height: 100%'
},{
'name': 'nav-search-box',
'style': 'display: flex; margin: 0; height: 100%; width: 100%; align-items: center; justify-content: center; padding-bottom: 150px'
},{
'name': 'nav-search',
'style': 'width: 500px'
},{
'name': 'nav-search-keyword',
'style': 'border: 1px solid #e5e9ef; padding: 0 10px; box-shadow: 0 2px 4px rgb(0 0 0 / 16%); height: 45px; font-size: 18px'
},{
'name': 'nav-user-center',
'style': 'display: inline-flex; flex-shrink: 0; flex-direction: row; align-self: flex-end; justify-items: flex-end;'
}
])
beauty_dom_by_id([
{
'name': 'nav_searchform',
'style': 'padding: 0'
}
])

const nav_search_keyword = document.getElementsByClassName('nav-search-keyword')[0]
nav_search_keyword.setAttribute('placeholder', search_box_holder)
nav_search_keyword.focus()
})


})();

function beauty_dom_by_className(targets){
targets.forEach(target => {
let dom = document.getElementsByClassName(target.name)
for(let i = 0; i < dom.length; i++){
dom[i].style.cssText = target.style;
}
});
}

function beauty_dom_by_id(targets){
targets.forEach(target => {
let dom = document.getElementById(target.name)
dom.style.cssText = target.style;
});
}

function delete_dom_by_className(names){
names.forEach(name => {
let dom = document.getElementsByClassName(name)
while(dom.length > 0){
dom[0].remove()
}
});
}
function delete_dom_by_id(ids){
ids.forEach(id => {
let dom = document.getElementById(id)
dom.remove()
});
}

效果图

启用脚本前:

before

启用脚本后:

after

TODO

  • 屏蔽没必要的请求, 加快加载速度
  • 添加一个商标头