// ==UserScript== // @name B站搜索页美化 // @namespace http://tampermonkey.net/ // @homepage https://github.com/Trrrrw/UserScript // @version 0.1.0 // @description 美化search.bilibili.com页面 // @author Trrrrw // @match https://search.bilibili.com/* // @grant GM_addStyle // @grant GM_addElement // @grant window.onload // @grant window.onurlchange // @icon https://www.bilibili.com/favicon.ico?v=1 // @license GPL-3.0 // @downloadURL none // ==/UserScript== (function () { //设置 var bgimg = 'https://i0.hdslb.com/bfs/new_dyn/2e762660113a84fe20affb3ec16eba386823116.jpg', //背景图片链接,可将此处链接修改 upBtnSwitch = 0; //投稿按钮是否显示,1-显示;0-删除 //删除元素 GM_addStyle('#biliMainFooter{display:none !important}') //footer GM_addStyle('.side-buttons{display:none !important}') //右下客服按钮 GM_addStyle('.right-entry-text{display:none !important}') //右上按钮文字 GM_addStyle('.center-title-text{display:none !important}') //搜索栏上方文字“搜索” GM_addStyle('.left-entry > .v-popover-wrap:nth-of-type(n+2){display:none !important}') //左上元素 GM_addStyle('.mini-header__title{display:none !important}') //左上bilibili图标右侧“首页” GM_addStyle('.search-panel:last-child{display:none !important}') if (!upBtnSwitch) { GM_addStyle('.right-entry-item--upload{display:none !important}') //投稿按钮 } //更改样式 //左上bilibili图标样式 GM_addStyle('.left-entry__title{margin-right: 0px !important}') //添加背景 GM_addStyle('#i_cecream{background: transparent;}') GM_addStyle('body{background: url(' + bgimg + ');}') GM_addStyle('body{background-size: cover;}') //header模糊效果 GM_addStyle('#bili-header-container{background: transparent !important}') GM_addStyle('.bili-header{background: transparent !important;}') GM_addStyle('.bili-header__bar{background: transparent !important;backdrop-filter: blur(10px) !important;}') //搜索框模糊效果 GM_addStyle('.search-input-wrap{background: transparent !important;backdrop-filter:blur(10px) !important;}') // //模糊动画 // GM_addElement('style', { // textContent: '@keyframes dim {from {backdrop-filter: blur(0px);} to {backdrop-filter: blur(10px);}}' // }); window.onload = function () { //搜索框预览文字 document.getElementsByClassName('search-input-el')[0].placeholder = '' //将左上图标链接改为搜索页 document.getElementsByClassName('left-entry__title')[0].href = '//search.bilibili.com/all'; //将首页添加至悬浮弹窗中 document.getElementsByClassName('v-popover-wrap')[0].onmouseenter = function () { if (document.getElementsByClassName('channel-panel__column')[0].children[0].innerText != '首页') { var honePage = ` 首页 `; document.getElementsByClassName('channel-panel__column')[0].insertAdjacentHTML('afterbegin', honePage); } } //搜索结果 window.addEventListener('urlchange', function (event) { const newUrl = event.state ? event.state.url : window.location.href; if (newUrl.includes('keyword')) { //背景模糊search-layout GM_addStyle('#i_cecream{background: #ffffff !important;}') } else { //移除背景模糊 GM_addStyle('#i_cecream{background: transparent !important;}') } }); //搜索栏选中模糊 document.onmouseup = function (e) { if (e.button == 0) { if (e.srcElement.className == 'search-input-el' && document.body.style.backdropFilter == '') { // document.body.style.animation = 'dim 1s forwards'; document.body.style.backdropFilter = 'blur(10px)'; } else if (e.srcElement.className != 'search-input-el' && document.body.style.backdropFilter == 'blur(10px)') { // document.body.style.animation = 'dim 1s reverse'; document.body.style.backdropFilter = ''; } } }; } })();