哔哩哔哩BILIBILI 美化|增强|自定义背景|评论过滤等

哔哩哔哩BILIBILI[开发中] 美化|增强|自定义背景|评论过滤等

目前为 2023-07-22 提交的版本。查看 最新版本

// ==UserScript==
// @name         BILIBILI-Beautify
// @name:zh      哔哩哔哩BILIBILI 美化|增强|自定义背景|评论过滤等
// @name:zh-CN   哔哩哔哩BILIBILI 美化|增强|自定义背景|评论过滤等
// @name:zh-TW   哔哩哔哩BILIBILI 美化|增强|自定义背景|评论过滤等
// @name:en      Beautify BILIBILI
// @name:ja      BILIBILI美化
// @namespace    http://github.com/yuhanawa/UserScript
// @version      0.1.5
// @description         Beautify BILIBILI[WIP]
// @description:zh      哔哩哔哩BILIBILI[开发中] 美化|增强|自定义背景|评论过滤等
// @description:zh-CN   哔哩哔哩BILIBILI[开发中] 美化|增强|自定义背景|评论过滤等
// @description:zh-TW   哔哩哔哩BILIBILI[开发中] 美化|增强|自定义背景|评论过滤等
// @description:en      Beautify BILIBILI[WIP] Bilibili beautification | enhancement | custom background | comment filtering, etc
// @description:ja     BILIBILI美化...
// @node         更新日志请见 https://github.com/yuhanawa/UserScript/blob/master/CHANGELOG.md
// @author       Yuhanawa
// @supportURL   http://github.com/yuhanawa/UserScript
// @license      GPL-3.0
// @match        *://*.bilibili.com/*
// @icon         none
// @run-at       document-start
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_addStyle
// @grant        GM_registerMenuCommand
// @match	*://yuhan-script-config.netlify.app/*
// @match	*://user-script-config-form.vercel.app/*
// @grant	unsafeWindow
// ==/UserScript==

function $get(k,d){return GM_getValue(k,d)}
function $set(k,v){return GM_setValue(k,v)}
function loadConfig(name,properties){GM_registerMenuCommand("打开设置中心(vercel|如果打不开点下一个)",()=>{location.href="https://user-script-config-form.vercel.app"}),GM_registerMenuCommand("打开设置中心(netlify|如果打不开点上一个)",()=>{location.href="https://yuhan-script-config.netlify.app"}),(location.href.match("yuhan-script-config.netlify.app")||location.href.match("user-script-config-form.vercel.app")||location.href.match("localhost"))&&(null==unsafeWindow.banana&&(unsafeWindow.banana={}),unsafeWindow.banana[name]={props:properties,get:$get,set:$set})}
function style(css){var node;"undefined"!=typeof GM_addStyle?GM_addStyle(css):((node=document.createElement("style")).appendChild(document.createTextNode(css)),document.body.appendChild(node))}
function option(name,key,options,current,index,onclick){return null!=current&&null!=index||(current=$set(key,getOptionKeyAndName(options[0]).key),index=options.indexOf(options.filter(x=>getOptionKeyAndName(x).key==current)[0])),-1!==index&&null!=index||($set(key,getOptionKeyAndName(options[0]).key),current=getOptionKeyAndName(options[index=0]).key),name+=`:${getOptionKeyAndName(options[index]).name}[${index+1}/${options.length}]<点击切换模式`,GM_registerMenuCommand(name,()=>{if(index+1>=options.length?$set(key,getOptionKeyAndName(options[0]).key):$set(key,getOptionKeyAndName(options[index+1]).key),onclick)try{onclick()}catch{}location.reload()}),index}
function onload(f){isLoaded?f():document.addEventListener("DOMContentLoaded",()=>f())}
function timeoutOnLoad(f,t){onload(()=>setTimeout(()=>f(),t))}
function intervalOnLoad(f,timeout){onload(()=>setInterval(f,timeout))}
function delay(fn,time,interval){(interval?intervalOnLoad:timeoutOnLoad)(fn,time)}
function run(fts){void 0===fts&&(fts=features);for(const key of Object.keys(fts)){var feature=fts[key];0!=feature.match.filter(m=>"string"==typeof m?null!==window.location.href.match(m):m.test(window.location.href)).length&&addFeature(key,feature)}}
function addFeature(key,feature){console.log(feature);var name=feature.name,values=feature.values,options=Object.keys(values),key0=getOptionKeyAndName(options[0]).key;let current=$get(key,key0),index=options.indexOf(options.filter(x=>getOptionKeyAndName(x).key==current)[0]);-1!==index&&null!=index||($set(key,key0),index=0,current=key0),option(name,key,options,current,index);try{var result,value=values[options[index]];null!=value&&("function"==typeof value?"string"==typeof(result=value(feature))&&style(result):"string"==typeof value?style(value):console.error(`出现了不应该出现的类型: ${typeof value} `+value))}catch(e){console.error(e)}}
function getOptionKeyAndName(optionStr){var key=optionStr.match(/\$([^ ]+)/)?.[0];return key?{key:key.replace("$",""),name:optionStr.replace(key,"")}:{key:optionStr,name:optionStr}}isLoaded=!1,onload(()=>isLoaded=!0);
loadConfig('bilibili', {"eye_protection_cover":{"title":"护眼蒙版","default":"on"},"eye_protection_cover_dark":{"title":"暗色模式护眼蒙版","default":"rgb(0 0 0 / 23%)"},"eye_protection_cover_light":{"title":"亮色模式护眼蒙版","default":"rgb(102 204 255 / 23%)"},"background_value":{"title":"自定义背景 可填颜色或url(图片链接)","default":"url(//s1.hdslb.com/bfs/static/stone-free/dyn-home/assets/bg.png)"},"test":{"title":"其他选项暂无完成","default":" {{{(>_<)}}} (不建议修改这个值)"}})
let features_bilibili_5403={
	bilibili_widescreen:{name:"视频页宽屏",match:["www.bilibili.com/video"],values:{"已开启$on":()=>(timeoutOnLoad(()=>{const player=document.getElementById("bilibili-player"),playerWarp=document.getElementById("playerWrap"),video=player.querySelector("video"),updateText=document.getElementsByClassName("pubdate-text")[0];let miniPlayerWarp=document.getElementsByClassName("bpx-player-mini-warp")[0],old_size={
	height:playerWarp.getBoundingClientRect().height,width:playerWarp.getBoundingClientRect().width},old_text=updateText.innerHTML,old_position="old",old_miniPlayerWarpDisplay="none";null!=miniPlayerWarp&&(old_miniPlayerWarpDisplay=miniPlayerWarp.style.display),delay(()=>{var position=window.getComputedStyle(player).position;let miniPlayerWarpDisplay="none";null!=(miniPlayerWarp=document.getElementsByClassName("bpx-player-mini-warp")[0])&&(miniPlayerWarpDisplay=miniPlayerWarp.style.display),old_position==position&&old_text==updateText.innerHTML&&old_miniPlayerWarpDisplay==miniPlayerWarpDisplay||("none"!=miniPlayerWarpDisplay?(playerWarp.style.height=old_size.height+"px",playerWarp.style.width=old_size.width+"px",video.style.maxHeight=""):(playerWarp.style.height="auto",playerWarp.style.width="auto",player.classList.contains("mode-webscreen")?(playerWarp.style.width="auto",playerWarp.style.marginLeft="0",player.style.width="100%",video.style.maxHeight=""):("relative"==position?(playerWarp.style.width="120%",playerWarp.style.marginLeft="7.2%",player.style.width="auto"):(playerWarp.style.width="auto",playerWarp.style.marginLeft="0",player.style.width="100%"),video.style.maxHeight="80vh"),old_position=position,old_text=updateText.innerHTML,old_miniPlayerWarpDisplay=miniPlayerWarpDisplay,old_size={
	height:playerWarp.getBoundingClientRect().height,width:playerWarp.getBoundingClientRect().width}))},200,!0)},500),'@charset "UTF-8";#app .video-container-v1{padding:0px 🔑YKnWlk.5px }#app .video-container-v1 #viewbox_report{height:auto;padding-bottom:22px}#app .video-container-v1 #viewbox_report h1{text-wrap:wrap}#app .video-container-v1 .left-container{width:auto!important;max-width:60vw}#app .video-container-v1 .left-container #playerWrap{height:auto}#app .video-container-v1 .left-container #playerWrap #bilibili-player{width:100%;height:100%}#app .video-container-v1 .left-container #playerWrap #bilibili-player .bpx-player-sending-area{margin-top:-1px}#app .video-container-v1 .left-container #playerWrap .mode-webscreen{height:100%!important}'.replace("🔑YKnWlk",$get("container_padding",60))),"已关闭$off":null}},
	bilibili_video_live_recommand:{name:"去除视频页直播推荐",match:["www.bilibili.com/video"],values:{"已开启$on":()=>".pop-live-small-mode{display:none;}","已关闭$off":null}},
	bilibili_video_beautify:{name:"视频页样式微调",match:["www.bilibili.com/video"],values:{"已开启$on":()=>"#app .video-container-v1 #viewbox_report h1{text-wrap:wrap}#app .video-container-v1 .left-container #playerWrap #bilibili-player .bpx-player-sending-area{margin-top:-1px}#app .video-container-v1 #live_recommand_report,#app .video-container-v1 .vcd{display:none!important}","已关闭$off":null}},
	bilibili_remove_keyword_search:{name:"移除评论关键字搜索跳转",match:["www.bilibili.com/video","www.bilibili.com/read"],values:{"移除图标$icon":()=>".icon.search-word:{display:none;}","移除图标和链接颜色$color":()=>".icon.search-word:{display:none;} .search-word a{color: #222!important;}","彻底移除$link":()=>(intervalOnLoad(()=>{var as=document.getElementsByClassName("search-word");for(let i=0;i<as.length;i++)as[i].parentElement.outerHTML=as[i].parentElement.outerHTML.replace(as[i].outerHTML,as[i].outerText)},8e3),".icon.search-word:{display:none;} .search-word a{color: #222!important;}"),"已关闭$off":null}},
	bilibili_quickly_copy:{name:"视频快捷分享复制模式",match:["www.bilibili.com/video"],values:{"[标题]链接$all":feature=>{intervalOnLoad(()=>{feature.fn("[标题]链接",`【${document.querySelector("h1.video-title").innerText}】	`+location.origin+location.pathname)},1200)},BV$BV:feature=>{intervalOnLoad(()=>{feature.fn("BV",location.pathname.split("/")[2])},1200)},"链接$url":feature=>{intervalOnLoad(()=>{feature.fn("链接",""+location.origin+location.pathname)},1200)},"标题$title":feature=>{intervalOnLoad(()=>{feature.fn("标题",""+document.querySelector("h1.video-title").innerText)},1200)},"关闭$off":null},fn:(title,text)=>{var copy_btn;-1===document.querySelector("h1.video-title").innerHTML.indexOf("🏷️")&&((copy_btn=document.createElement("span")).title="复制当前视频的"+title,copy_btn.style.cursor="pointer",copy_btn.innerText="🏷️",copy_btn.addEventListener("click",()=>navigator.clipboard.writeText(text)),document.querySelector("h1.video-title").append(copy_btn))}},
	bilibili_filter:{name:"bilibili评论过滤[BETA]",match:["www.bilibili.com/video","www.bilibili.com/read"],values:{"测试中$beta":null,"已开启_测试_$on":f=>{const check=x=>{try{var ctx=x.getElementsByClassName("reply-content")[0];if(!x.classList.contains("🎇checked")&&""!==ctx.innerHTML&&(x.classList.add("🎇checked"),!(Number(ctx.outerText)>$get("bilibili_filter_length_limit",25)||""!==ctx.innerHTML&&""===ctx.innerText)))for(const r of f.rules)if(r.test(x.getElementsByClassName("reply-content")[0].outerText)){x.classList.add("🎇filtered"),console.log(`已屏蔽: ${x.getElementsByClassName("reply-content")[0].outerText} 
 规则: `+r.toString());break}}catch(e){x.classList.add("🎇checked")}
};return intervalOnLoad(()=>{for(const x of document.getElementsByClassName("reply-item"))check(x);for(const x of document.getElementsByClassName("sub-reply-item"))check(x)},2e3),".🎇filtered{display:none;}"},"已关闭$off":null},rules:[/^.?6{1,12}.?$/,/考古/,/^.{0,8}小号.{0,8}$/,/^(@.{1,12}\s?.{0,12}){1,24}$/,/压缩毛巾/,/你说得对/,/答辩/,/爷/]},bilibili_beautify:{name:"样式美化 | 自定义背景 | 大幅度修改",match:["bilibili.com"],values:{"已开启$on":()=>("on"===$get("bilibili_eye_protection_cover","on")?style("html,:root{--bodybackground: "+(window.matchMedia("(prefers-color-scheme: dark)").matches?$get("bilibili_eye_protection_cover_dark","rgb(0 0 0 / 23%)"):$get("bilibili_eye_protection_cover_light","rgb(102 204 255 / 23%)"))+"}"):style("html,:root{--bodybackground:transparent}"),style(`html,:root{--background:${$get("bilibili_background_value","url(//s1.hdslb.com/bfs/static/stone-free/dyn-home/assets/bg.png)")}}`),":root,html{background-attachment:fixed!important;background:var(--background);background-repeat:no-repeat repeat;background-size:100% 100%;bottom:0;--text3:var(--text2)}:root body,html body{background-color:transparent;background:var(--bodybackground);height:auto}:root body .app-v1,:root body .fixed-reply-box,:root body .visitor,html body .app-v1,html body .fixed-reply-box,html body .visitor{background-color:rgba(255,255,255,.68)!important}:root body .fixed-reply-box,:root body .left-container-under-player,:root body .right-container,:root body .visitor,html body .fixed-reply-box,html body .left-container-under-player,html body .right-container,html body .visitor{opacity:.97}:root body .act-end,:root body .activity-m-v1,html body .act-end,html body .activity-m-v1{border-radius:12px}:root body .bili-comment,:root body .browser-pc,html body .bili-comment,html body .browser-pc{background-color:rgba(255,255,255,.68)!important;border-radius:10px;padding:0;margin:0}:root body #comment,html body #comment{box-shadow:0 0 4px #f5f5f5;margin-top:2px;padding:0;border-radius:10px}:root body #comment .reply-list,html body #comment .reply-list{padding:0 18px 0 2px}:root body .left-container-under-player,html body .left-container-under-player{background-color:transparent!important}:root body #arc_toolbar_report,html body #arc_toolbar_report{margin-top:-5px;padding-top:20px;padding-left:12px;padding-right:12px;border:0;opacity:.8;background-color:rgba(255,255,255,.65)!important;border-radius:0 0 6px 6px}:root body .video-desc-container,html body .video-desc-container{padding:10px 8px 14px;margin:0;opacity:.68}:root body .video-tag-container,html body .video-tag-container{margin:0;padding:8px 2px 2px;border-style:dashed;border-width:1px 0;border-color:#e3e5e7;border-color:var(--text4)}:root body .tag-link .newchannel-link,:root body .video-tag-container .tag-panel a,html body .tag-link .newchannel-link,html body .video-tag-container .tag-panel a{background:#fff}:root body .bili-header__bar .mini-header,html body .bili-header__bar .mini-header{opacity:.96}:root body .bpx-player-video-area,:root body video,html body .bpx-player-video-area,html body video{border-radius:4px 4px 0 0}:root body .reply-header,html body .reply-header{margin:0 0-4px 14px;padding:12px 0 0 2px}:root body .reply-box,html body .reply-box{padding-right:16px!important}:root body .danmaku-wrap>.bpx-docker,html body .danmaku-wrap>.bpx-docker{background:0 0}:root body #bilibili-player-placeholder,html body #bilibili-player-placeholder{box-shadow:0-2px 4px 1px rgba(255,255,255,.1);border-radius:4px 4px 12px 12px}:root body #bilibili-player-placeholder #bilibili-player-placeholder-top,html body #bilibili-player-placeholder #bilibili-player-placeholder-top{border-radius:4px 4px 0 0;background:0 0!important}:root body #bilibili-player-placeholder #bilibili-player-placeholder-bottom,html body #bilibili-player-placeholder #bilibili-player-placeholder-bottom{border-radius:0 0 12px 12px}"),"已关闭$off":null}}
};

run(features_bilibili_5403);

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址