// ==UserScript==
// @name BILIBILI-Beautify
// @name:zh 哔哩哔哩BILIBILI 美化|增强|自定义背景|评论过滤等
// @name:zh-CN 哔哩哔哩BILIBILI 美化|增强|自定义背景|评论过滤等
// @name:zh-TW 哔哩哔哩BILIBILI 美化|增强|自定义背景|评论过滤等
// @name:en BILIBIL Beautify Ienhancement custom background
// @name:ja BILIBILI 美化|強化|カスタム背景|レビューフィルタリング
// @namespace http://github.com/yuhanawa/UserScript
// @version 0.1.15
// @description Bilibili beautification | enhancement | custom background | comment filtering, etc
// @description:zh 哔哩哔哩BILIBILI 美化|增强|自定义背景|宽屏|标题快速复制|评论过滤等
// @description:zh-CN 哔哩哔哩BILIBILI 美化|增强|自定义背景|宽屏|标题快速复制|评论过滤等
// @description:zh-TW 哔哩哔哩BILIBILI 美化|增强|自定义背景|宽屏|标题快速复制|评论过滤等
// @description:en Bilibili beautification | enhancement | custom background | comment filtering, etc
// @description:ja BILIBILI 美化|強化|カスタム背景|レビューフィルタリングなど
// @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==
/*
bilibili v.0.1.15 by Yuhanawa
Source: https://github.com/Yuhanawa/UserScript
*/
isLoaded=!1,onload(()=>isLoaded=!0);const __props__=new Map;
function $get(k,d){return void 0===d?GM_getValue(k,__props__.get(k)):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"}),Object.keys(properties).forEach(key=>__props__.set(name+"_"+key,properties[key].default)),(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){var{name,values}=feature;if("$"===name)try{"function"==typeof values?"string"==typeof(result=values(feature))&&style(result):"string"==typeof values&&style(value)}catch(e){console.error(e)}else{var result=Object.keys(values),key0=getOptionKeyAndName(result[0]).key;let current=$get(key,key0),index=result.findIndex(x=>getOptionKeyAndName(x).key===current);-1!==index&&null!=index||($set(key,key0),index=0,current=key0),option(name,key,result,current,index);try{const value=values[result[index]];if(null!==value&&void 0!==value)if("function"==typeof value){const result=value(feature);"string"==typeof result&&style(result)}else"string"==typeof value&&style(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}}
loadConfig('bilibili', {"line_ts":{"widget":"line","title":"如果发现某条设置存在问题请反馈: https://gf.qytechs.cn/zh-CN/scripts/471069/feedback/"},"line_bc":{"widget":"line","title":"❗❗❗修改完记得点保存(在最下面)❗❗❗"},"line_mh":{"widget":"line","title":"美化","description":"美化设置"},"beautify":{"title":"样式美化","default":"on","widget":"select","props":{"options":[{"label":"开启","value":"on"},{"label":"关闭","value":"off"}]}},"beautify_work_on_index":{"title":"美化首页(前置功能:样式美化)","default":"on","widget":"select","props":{"options":[{"label":"开启","value":"on"},{"label":"关闭","value":"off"}]}},"background_value":{"title":"自定义背景 可填颜色或url(图片链接)(前置功能:样式美化)","default":"url(//s1.hdslb.com/bfs/static/stone-free/dyn-home/assets/bg.png)"},"widescreen":{"title":"宽屏功能","default":"on","widget":"select","props":{"options":[{"label":"开启","value":"on"},{"label":"关闭","value":"off"}]}},"container_padding":{"title":"宽屏宽度(其它宽度未测试,不建议修改)","default":"60"},"line_mb":{"widget":"line","title":"护眼蒙版(前置功能:样式美化)","description":"会在屏幕上添加一个半透明的蒙版"},"eye_protection_cover":{"title":"护眼蒙版(前置功能:样式美化)","default":"on","widget":"select","props":{"options":[{"label":"开启","value":"on"},{"label":"关闭","value":"off"}]}},"eye_protection_cover_dark":{"title":"暗色模式护眼蒙版(前置功能:护眼蒙版)","default":"rgb(0 0 0 / 23%)"},"eye_protection_cover_light":{"title":"亮色模式护眼蒙版(前置功能:护眼蒙版)","default":"rgb(102 204 255 / 23%)"},"line_gn":{"widget":"line","title":"功能","description":"实用功能"},"quickly_copy":{"title":"标题快速复制","default":"all","widget":"select","props":{"options":[{"label":"[标题]链接","value":"all"},{"label":"BV","value":"BV"},{"label":"链接","value":"url"},{"label":"标题","value":"title"},{"label":"关闭","value":"off"}]}},"quickly_copy_hotkey":{"title":"Ctrl+Shirt+C快速复制标题(前置功能:标题快速复制)","default":"off","widget":"select","props":{"options":[{"label":"开启","value":"on"},{"label":"关闭","value":"off"}]}},"hotkey":{"title":"快捷键增强(暂时只支持按ESC关闭图片)","default":"on","description":"<-明明只是个简单的功能阿B却不做,真是太懒了(~ ̄(OO) ̄)ブ <- 这个人只写了一个快捷键还说别人懒 ̄へ ̄","widget":"select","props":{"options":[{"label":"开启","value":"on"},{"label":"关闭","value":"off"}]}},"remove_keyword_search":{"title":"移除评论关键字搜索跳转","description":"就是那个旁边带个放大镜的蓝字","default":"icon","widget":"select","props":{"options":[{"label":"移除图标","value":"icon"},{"label":"移除图标和链接颜色(仍可点击)","value":"color"},{"label":"彻底移除","value":"link"},{"label":"关闭","value":"off"}]}},"line_xz":{"widget":"line","title":"小众功能","description":"小众功能"},"information_diet":{"title":"首页信息节食(前置功能:样式美化)","description":"⚠️限制首页视频加载数量⚠️","default":"off","widget":"select","props":{"options":[{"label":"开启","value":"on"},{"label":"关闭","value":"off"}]}},"information_diet_num":{"title":"首页视频加载数量(前置功能:信息节食)","description":"单位(屏)","default":"8"}})
let features_bilibili_6815352={
bilibili_widescreen_beta:{name:"视频页宽屏",match:["www.bilibili.com/video"],values:{"已开启$on":()=>(style(`#app{--container_padding:${$get("bilibili-container-padding",60)}}`),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_height=playerWarp.getBoundingClientRect().height,old_isFullScreen=Boolean(document.fullscreenElement),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&&old_isFullScreen==Boolean(document.fullscreenElement)||(old_text!=updateText.innerHTML&&(playerWarp.style.height="auto",playerWarp.style.width="auto"),"none"!=miniPlayerWarpDisplay?(playerWarp.style.height=old_height+"px",video.style.maxHeight=""):(document.fullscreenElement||player.classList.contains("mode-webscreen")?(playerWarp.style.width="auto",playerWarp.style.marginLeft="0",player.style.width="100%",video.style.maxHeight="100%"):("relative"==position?(playerWarp.style.height="auto",playerWarp.style.width="120%",playerWarp.style.marginLeft="7.2%",player.style.width="auto"):(playerWarp.style.height=old_height+"px",playerWarp.style.width="auto",playerWarp.style.marginLeft="0",player.style.width="100%"),video.style.maxHeight="80vh"),old_position=position,old_isFullScreen=Boolean(document.fullscreenElement),old_text=updateText.innerHTML,old_miniPlayerWarpDisplay=miniPlayerWarpDisplay,old_height=playerWarp.getBoundingClientRect().height))},200,!0)},500),"#app .video-container-v1{padding:0 var(--container_padding) .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}"),"已关闭$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_skeleton_after_adb:{name:"移除空白卡片(广告被插件屏蔽后的区域)(卡顿)(不建议开启)(需安装广告屏蔽插件)",match:["www.bilibili.com"],values:{"已关闭$off":null,"已开启$on":()=>(timeoutOnLoad(()=>{for(const card of document.getElementsByClassName("feed-card"))0<card.getElementsByClassName("🎇filtered").length&&card.classList.add("🎇filtered")},2400),intervalOnLoad(()=>{for(const card of document.getElementsByClassName("bili-video-card"))try{!card.classList.contains("🎇checked")&&(card.classList.add("🎇checked"),null==card.getElementsByClassName("bili-video-card__wrap")[0]&&0<card.getElementsByClassName("hide").length||"none"===card.getElementsByClassName("bili-video-card__wrap")[0].style.display)&&card.classList.add("🎇filtered")}catch(e){card.classList.add("🎇checked")}},
2e3),".🎇filtered{display:none;}")}},
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_remove_floor_single_card:{name:"移除首页右侧特殊卡片",match:["www.bilibili.com"],values:{"已关闭$off":null,"已开启$on":".floor-single-card{display:none;}"}},
bilibili_remove_carousel:{name:"移除首页轮播图",match:["www.bilibili.com"],values:{"已关闭$off":null,"已开启$on":".recommended-swipe{display:none;}"}},
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),"on"===$get("quickly_copy_hotkey","off"))&&document.addEventListener("keydown",e=>{e.ctrlKey&&e.shiftKey&&"c"===e.key&&navigator.clipboard.writeText(text)})}},
bilibili_hotkey:{name:"快捷键增强",match:["bilibili.com"],values:{"已开启$on":()=>{location.href.match("www.bilibili.com/video")&&intervalOnLoad(()=>{const img_view=document.querySelector(".reply-view-image");null!=img_view&&img_view.addEventListener("keydown",e=>{"Escape"==e.key&&img_view.getElementsByClassName("close-container")[0].click(),"a"!=e.key&&"ArrowLeft"!=e.key||img_view.getElementsByClassName("last-image")[0].click(),"d"!=e.key&&"ArrowRight"!=e.key||img_view.getElementsByClassName("next-image")[0].click()})},400)},"已关闭$off":null}},
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:["www.bilibili.com"],values:{"已开启$on":()=>{if("https://www.bilibili.com/"!==location.href||"off"!==$get("bilibili_beautify_work_on_index","on"))return"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}"),"on"===$get("bilibili_information_diet","off")&&style(`.container{max-height: ${$get("bilibili_information_diet_num","8")}00vh;overflow: hidden;}`),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 .bili-live-card__wrap,:root body .bili-video-card__wrap,:root body .floor-card-inner,html body .bili-live-card__wrap,html body .bili-video-card__wrap,html body .floor-card-inner{background-color:rgba(255,255,255,.72)!important}:root body #i_cecream,html body #i_cecream{background-color:rgba(255,255,255,.24)!important}:root body .bili-header,:root body .bili-header__channel,html body .bili-header,html body .bili-header__channel{background-color:transparent}:root body #activity_vote .right ::after,:root body .act-end .right ::after,:root body .activity-m-v1 .right ::after,:root body .floor-single-card .layer,html body #activity_vote .right ::after,html body .act-end .right ::after,html body .activity-m-v1 .right ::after,html body .floor-single-card .layer{display:none}:root body .floor-card,html body .floor-card{background:0 0}:root body .bili-video-card__wrap,html body .bili-video-card__wrap{padding:2px 2px 4px;border-radius:8px}:root body .bili-live-card__wrap,html body .bili-live-card__wrap{border-radius:8px}:root body .bili-live-card__wrap .bili-live-card__info,:root body .bili-live-card__wrap .bili-video-card__info,:root body .bili-video-card__wrap .bili-live-card__info,:root body .bili-video-card__wrap .bili-video-card__info,html body .bili-live-card__wrap .bili-live-card__info,html body .bili-live-card__wrap .bili-video-card__info,html body .bili-video-card__wrap .bili-live-card__info,html body .bili-video-card__wrap .bili-video-card__info{padding:0 4px 4px}:root body .bili-live-card__wrap,html body .bili-live-card__wrap{padding:2px 2px 24px}: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 #activity_vote,:root body .act-end,:root body .activity-m-v1,html body #activity_vote,html body .act-end,html body .activity-m-v1{border-radius:12px;background:rgba(255,255,255,.72);opacity:.97}:root body #activity_vote .right .b-img,:root body .act-end .right .b-img,:root body .activity-m-v1 .right .b-img,html body #activity_vote .right .b-img,html body .act-end .right .b-img,html body .activity-m-v1 .right .b-img{mask:linear-gradient(90deg,transparent,#fff)}: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_6815352);