Greasy Fork

Greasy Fork is available in English.

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

哔哩哔哩BILIBILI 美化|增强|自定义背景|宽屏|标题快速复制|评论过滤等

当前为 2024-07-27 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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.2.1
// @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
// @grant        unsafeWindow
// ==/UserScript==

/* 
	 source: https://github.com/Yuhanawa/UserScript/; 
	 version: 0.1.42; 
 */
(function() {

var config = {"version":"0.1.42","name":"bilibili","pages":{"home":["www.bilibili.com"],"video":["www.bilibili.com/video"],"read":["www.bilibili.com/read"]},"category":[{"key":"tips","display":"tips","icon":"note-icon"},{"key":"beautify","display":"美化","icon":"beautify-icon"},{"key":"optimize","display":"优化","icon":"optimize-icon"},{"key":"useful","display":"实用","icon":"useful-icon"},{"key":"filter","display":"过滤","icon":"filter-icon"}],"props":{"tips":{"type":"note","category":"tips","display":"如果发现某条设置存在问题请反馈: http://greasyfork.icu/zh-CN/scripts/471069/feedback/"},"tips-refresh":{"type":"note","category":"tips","display":"修改完成后请刷新页面"},"tips-beautify":{"type":"note","category":"beautify","display":"-- 美化 --"},"beautify":{"display":"样式美化","type":"bool","category":"beautify","defaultValue":true,"description":"此功能是部分功能的前置功能"},"beautify_work_on_index":{"display":"是否在首页启用样式美化","category":"beautify","type":"bool","defaultValue":true,"description":"前置功能:样式美化","hidden":"{{ formData.beautify === 'off' }}"},"background":{"display":"自定义背景开关","category":"beautify","type":"bool","defaultValue":true,"description":"前置功能:样式美化","hidden":"{{ formData.beautify === 'off' }}"},"background_value":{"display":"自定义背景","defaultValue":"https://s1.hdslb.com/bfs/static/stone-free/dyn-home/assets/bg.png","category":"beautify","hidden":"{{ formData.beautify === 'off' }}","description":"前置功能:自定义背景开关","tooltip":"填图片链接或者上传图片","type":"image"},"video_radius":{"display":"视频小圆角","category":"beautify","type":"bool","defaultValue":true,"hidden":"{{ formData.beautify === 'off' }}"},"tips-video-beautify":{"type":"note","category":"beautify","display":"-- 视频页美化 --"},"video_beautify":{"display":"视频页美化","category":"beautify","type":"bool","defaultValue":true},"widescreen":{"display":"宽屏功能","category":"beautify","type":"bool","defaultValue":true},"widescreen-width-times":{"display":"宽屏倍数","type":"number","defaultValue":1.2,"required":true,"hidden":"{{ formData.widescreen === 'off' }}","category":"beautify","tooltip":"单位: 倍","description":"前置功能:宽屏功能|推荐范围1.00~1.30倍"},"widescreen_hide_header_onWide":{"display":"剧场模式下隐藏网页顶部菜单","type":"bool","category":"beautify","defaultValue":false,"description":"前置功能:宽屏功能","hidden":"{{ formData.widescreen === 'off' }}"},"tips-optimize":{"type":"note","category":"optimize","display":"-- 优化 --"},"ad":{"display":"移除广告","category":"optimize","type":"bool","defaultValue":true},"remove_keyword_search":{"display":"移除关键词搜索标志(失效)","category":"optimize","type":"option","options":[{"key":"icon","display":"隐藏🔍图标"},{"key":"color","display":"隐藏图标和恢复颜色"},{"key":"link","display":"彻底移除"},{"key":"off","display":"已关闭"}],"defaultValue":"icon"},"video_live_recommand":{"display":"去除视频页直播推荐","category":"optimize","type":"bool","defaultValue":true},"tips-useful":{"type":"note","category":"useful","display":"-- 实用 --"},"quickly_copy":{"display":"标题快捷复制","type":"option","category":"useful","defaultValue":"all","options":[{"key":"all","display":"[标题]链接"},{"key":"BV","display":"BV"},{"key":"url","display":"链接"},{"key":"title","display":"标题"},{"key":"off","display":"已关闭"}]},"video_cover_download":{"display":"视频封面获取","type":"bool","category":"useful","defaultValue":true},"hotkey":{"display":"按ESC关闭评论区图片","category":"useful","defaultValue":true,"description":"","type":"bool"},"tips-filter":{"type":"note","category":"filter","display":"-- 过滤 --"},"filter":{"display":"评论过滤","category":"filter","type":"bool","description":"此功能为经测试,可能存在bug","defaultValue":false},"filter_rules":{"display":"正则过滤规则","type":"richtext","defaultValue":"/^.?6{1,12}.?$/ \n/^(@.{1,12}\\s?.{0,12}){1,24}$/ \n/压缩毛巾/ \n/答辩/ \n/爷/ \n/谁问你了/ \n/亡灵军团/ \n/死灵法师/ \n","category":"filter","props":{"placeholder":"","autoSize":true},"description":"此功能为经测试,可能存在bug","tooltip":{"title":"使用正则表达式,一行一个"},"hidden":"{{ formData.filter === 'off' }}"}}};
const win = unsafeWindow;
isLoaded = false;

//#region utils: onload delay loop
function onload(f) {
    if (isLoaded) f(); else document.addEventListener("DOMContentLoaded", () => f())
};
function delay(f, t, delayConfig) {
    const afterLoad = delayConfig?.afterLoad ?? true
    const loop = delayConfig?.loop ?? false
    const runOnFirst = delayConfig?.runOnFirst ?? false

    const run = afterLoad ? onload : (f) => f()
    if (loop) {
        if (runOnFirst) run(f)
        run(() => setInterval(f, t))
    }
    else run(() => setTimeout(f, t))
}
function loop(f, t, loopConfig) {
    delay(f, t, { ...loopConfig, loop: true })
}
//#endregion

onload(() => { isLoaded = true });

//#region config: get set cfg
function get(k, d) { return GM_getValue(k, d === undefined ? config.props[k]?.defaultValue ?? console.error(`Can't found key (${k}) in config.`) : d) }
function set(k, v) { return GM_setValue(k, v) }
function cfg(k, v) { return v === undefined ? get(k) : set(k, v) }
//#endregion

//#region settingCustomWidgets
const settingCustomWidgets = []
function addSettingWidget(type, creatorFunction) { settingCustomWidgets.push({ type, creatorFunction }) }
//#endregion

//#region style
function style(css, id) {
    if (id || typeof GM_addStyle === "undefined") {
        const node = document.createElement("style");
        if (id) node.setAttribute("id", id);
        node.appendChild(document.createTextNode(css));
        if (document.body) document.body.appendChild(node);
        else document.head.appendChild(node);
        return node;
    }
    // else direct add
    GM_addStyle(css);
}
//#endregion

//#region Menu: addOptionOnMenu addButtonOnMenu
function addOptionOnMenu(key, reload = true) {
    const configProps = config.props;
    if (!configProps || !configProps[key]) {
        console.error(`addOptionOnMenu: Can't find config key "${key}"`);
        return;
    }

    try {
        const { category, display, defaultValue, type, options } = configProps[key]
        const current = cfg(key);

        if (type === "bool") {
            const menuDisplay = `${configProps[key]?.display}:${current ? "已启用" : "已禁用"}`;
            // noinspection JSUnresolvedFunction
            GM_registerMenuCommand(menuDisplay, () => {
                cfg(key, !current);
                if (reload) location.reload();

            });
        } else if (type === "option") {
            let index = options.findIndex(o => o.key === current);
            if (index === -1) { cfg(key, options[0].key); index = 0 }

            const menuDisplay = `${configProps[key]?.display}:${current} [${index + 1}/${options.length}]`;
            // noinspection JSUnresolvedFunction
            GM_registerMenuCommand(menuDisplay, () => {
                const nextIndex = (index + 1) % options.length;
                cfg(key, options[nextIndex].key);
                if (reload) location.reload();

            });

        } else {
            console.error(`addOptionOnMenu: Unsupported type "${type}" for key "${key}"`);
            return;
        }
    } catch (error) {
        console.error(`addOptionOnMenu: An error occurred when add "${key}", ${error}`);
    }
}
function addButtonOnMenu(display, onclick, reload = true) {
    // noinspection JSUnresolvedFunction
    GM_registerMenuCommand(display, () => {
        if (onclick) {
            try {
                onclick()
            } catch (e) {
                console.error(`addButtonOnMenu: An error occurred when add "${display}", ${e}`);
            }
        }
        if (reload) location.reload();
    });
}
//#endregion

//#region Module: addModule
function addModule(module) {
    const condition = module.condition
    if (condition !== undefined && (
        (typeof condition === "boolean" && !condition)
        || (typeof condition === "function" && !condition()))) return;

    const pages = module.pages
    let isMatchedPage = undefined;
    // biome-ignore lint/suspicious/noAssignInExpressions: <explanation>
    if (pages !== undefined && !(isMatchedPage = pages.some(page => config.isMatchedPages[page]))) return;
    if ((pages === undefined && module.matchUrls !== undefined) || isMatchedPage === false) {
        const urls = module.matchUrls
        if (urls !== undefined && !urls.some(testUrlMatched)) return;
    }

    if (module.showInMenu) {
        if (module.runAlways) addButtonOnMenu(`${module.key}: runAlways`, () => { }, false);
        else addOptionOnMenu(module.key);
    }

    let cfgValue = null;
    // biome-ignore lint/suspicious/noAssignInExpressions: <explanation>
    if (module.runAlways || (cfgValue = cfg(module.key)) === true || typeof module.value === "object") {
        let moduleValue = module.value;
        if (typeof module.value === "object")
            moduleValue = module.value[cfgValue];

        if (typeof moduleValue === "string") style(moduleValue);
        else if (typeof moduleValue === "function") {
            try {
                const result = moduleValue(module);
                if (typeof result === "string") style(result);
            } catch (e) {
                console.error("An error occurred when addModeModule", e);
            }
        } else if (typeof moduleValue === "undefined" || moduleValue === null) {
            // do nothing
        }
        else console.error("异常的module.value在addModeModule中", module.value);
    }
}
//#endregion

//#region MatchUtils: testUrlMatched initIsMatchedPages
function testUrlMatched(url) {
    return url.startsWith("/") && url.endsWith("/") ?
        new RegExp(url.substring(1, url.length - 1)).test(location.href)
        : location.href.includes(url)
}
function initIsMatchedPages() {
    if (!config.pages) return;
    config.isMatchedPages = {}

    for (const key of Object.keys(config.pages)) {
        config.isMatchedPages[key] = config.pages[key].some(testUrlMatched);
    }

}
//#endregion

//#region init
addButtonOnMenu("⚙️", openConfigPanel, false);
initIsMatchedPages();
//#endregion

let _openConfigPanel = null;
const openConfigPanel = () => {
    if (_openConfigPanel) { _openConfigPanel(); return; }

    const container = document.createElement('div');
    container.id = "userscript-setting-shadow-container";
    container.style = "all: initial;";
    const shadowRoot = container.attachShadow({ mode: 'open' });
    const root = document.createElement('div');

    root.innerHTML = `<style>*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]{display:none}*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }.container{width:100%}@media (min-width: 640px){.container{max-width:640px}}@media (min-width: 768px){.container{max-width:768px}}@media (min-width: 1024px){.container{max-width:1024px}}@media (min-width: 1280px){.container{max-width:1280px}}@media (min-width: 1536px){.container{max-width:1536px}}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.visible{visibility:visible}.invisible{visibility:hidden}.absolute{position:absolute}.relative{position:relative}.-bottom-1{bottom:-.25rem}.left-1{left:.25rem}.left-1\/2{left:50%}.top-1{top:.25rem}.z-10{z-index:10}.mb-2{margin-bottom:.5rem}.mb-4{margin-bottom:1rem}.mb-6{margin-bottom:1.5rem}.me-2{margin-inline-end:.5rem}.ml-2{margin-left:.5rem}.mr-3{margin-right:.75rem}.mt-1{margin-top:.25rem}.mt-2{margin-top:.5rem}.block{display:block}.flex{display:flex}.inline-flex{display:inline-flex}.hidden{display:none}.h-10{height:2.5rem}.h-24{height:6rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-8{height:2rem}.h-full{height:100%}.max-h-48{max-height:12rem}.w-10{width:2.5rem}.w-14{width:3.5rem}.w-4{width:1rem}.w-5{width:1.25rem}.w-6{width:1.5rem}.w-full{width:100%}.max-w-xs{max-width:20rem}.flex-shrink-0{flex-shrink:0}.-translate-x-1\/2{--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-6{--tw-translate-x: 1.5rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.cursor-help{cursor:help}.cursor-pointer{cursor:pointer}.flex-col{flex-direction:column}.items-start{align-items:flex-start}.items-center{align-items:center}.justify-between{justify-content:space-between}.space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(.5rem * var(--tw-space-x-reverse));margin-left:calc(.5rem * calc(1 - var(--tw-space-x-reverse)))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.whitespace-nowrap{white-space:nowrap}.rounded{border-radius:.25rem}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.border{border-width:1px}.border-0{border-width:0px}.border-l-4{border-left-width:4px}.border-blue-500{--tw-border-opacity: 1;border-color:rgb(59 130 246 / var(--tw-border-opacity))}.border-gray-300{--tw-border-opacity: 1;border-color:rgb(209 213 219 / var(--tw-border-opacity))}.bg-blue-50{--tw-bg-opacity: 1;background-color:rgb(239 246 255 / var(--tw-bg-opacity))}.bg-blue-600{--tw-bg-opacity: 1;background-color:rgb(37 99 235 / var(--tw-bg-opacity))}.bg-blue-700{--tw-bg-opacity: 1;background-color:rgb(29 78 216 / var(--tw-bg-opacity))}.bg-gray-200{--tw-bg-opacity: 1;background-color:rgb(229 231 235 / var(--tw-bg-opacity))}.bg-gray-50{--tw-bg-opacity: 1;background-color:rgb(249 250 251 / var(--tw-bg-opacity))}.bg-gray-600{--tw-bg-opacity: 1;background-color:rgb(75 85 99 / var(--tw-bg-opacity))}.bg-gray-800{--tw-bg-opacity: 1;background-color:rgb(31 41 55 / var(--tw-bg-opacity))}.bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity))}.object-contain{-o-object-fit:contain;object-fit:contain}.p-2{padding:.5rem}.p-2\.5{padding:.625rem}.p-4{padding:1rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-4{padding-left:1rem;padding-right:1rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xs{font-size:.75rem;line-height:1rem}.font-medium{font-weight:500}.leading-relaxed{line-height:1.625}.text-blue-700{--tw-text-opacity: 1;color:rgb(29 78 216 / var(--tw-text-opacity))}.text-gray-400{--tw-text-opacity: 1;color:rgb(156 163 175 / var(--tw-text-opacity))}.text-gray-500{--tw-text-opacity: 1;color:rgb(107 114 128 / var(--tw-text-opacity))}.text-gray-600{--tw-text-opacity: 1;color:rgb(75 85 99 / var(--tw-text-opacity))}.text-gray-700{--tw-text-opacity: 1;color:rgb(55 65 81 / var(--tw-text-opacity))}.text-gray-900{--tw-text-opacity: 1;color:rgb(17 24 39 / var(--tw-text-opacity))}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity))}.opacity-0{opacity:0}.opacity-100{opacity:1}.shadow-md{--tw-shadow: 0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);--tw-shadow-colored: 0 4px 6px -1px var(--tw-shadow-color), 0 2px 4px -2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-opacity{transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-300{transition-duration:.3s}.ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}.topmost{display:flex!important;position:fixed!important;z-index:5201314!important;width:100%!important;height:100%!important;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-rendering:optimizeLegibility}.main-container{position:fixed;top:50%;left:50%;transform:translate(-50%,-50%)}.floating-ball{display:flex;position:fixed;z-index:5201314;top:72vh;left:0;width:32px;height:32px;padding:6px;opacity:.5;transition:.2s;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;user-select:none;flex-direction:column;align-items:center;justify-content:center;box-sizing:content-box;-webkit-tap-highlight-color:transparent;transform-origin:center;transform:translate(-8px);transition:transform .3s ease;background:#e3fdf5aa;-webkit-backdrop-filter:blur(5px);backdrop-filter:blur(5px);box-shadow:0 4px 6px #42275a1a,0 1px 3px #b682ae14;border-radius:0 45% 45% 0;color:#bfe2d1;font-size:large}.floating-ball:hover{opacity:.8;background:#ffd5f7;border-radius:40%;transition:all .3s ease-out;font-size:x-large;box-shadow:0 7px 14px #42275a26,0 3px 6px #b682ae1a;transform:translate(8px) scale(1.1)}.toolbar{display:flex;flex-wrap:nowrap;flex-direction:row;justify-content:space-between;cursor:move}.panel{animation-fill-mode:forwards;transition:opacity .3s ease,visibility .3s ease;height:65vh;width:-moz-fit-content;width:fit-content;position:static;padding:4px;overflow:hidden;color:#fff;justify-content:center;align-items:center;gap:20px;border-radius:10px;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);background-color:#171717bf;box-shadow:#0000004d 2px 8px 8px;border:1px rgba(255,255,255,.4) solid;border-bottom:1px rgba(40,40,40,.35) solid;border-right:1px rgba(40,40,40,.35) solid}.panel,.panel *{text-shadow:0 0 1px rgba(0,0,0,.3)}.panel:not(.hidden){animation:slideIn .45s cubic-bezier(.25,.8,.25,1) forwards}@keyframes slideIn{0%{transform:translate(-100%) scale(.85);opacity:0}to{transform:translate(0) scale(1);opacity:1}}.panel.hidden{animation:slideOut .25s cubic-bezier(.25,.45,.75,.25) forwards}@keyframes slideOut{0%{transform:translate(0) scale(1);display:block;opacity:1}to{transform:translate(-150%) scale(.8);display:none;opacity:0}}.panel-main{transition:.3s cubic-bezier(.25,.8,.25,1);animation-fill-mode:forwards;padding:4px;width:100%;height:calc(100% - 30px);display:flex;flex-direction:row;flex-wrap:nowrap;justify-content:space-between;gap:.5rem}.category-container{max-width:200px;overflow-x:hidden;overflow-y:auto}.content-container{overflow-y:auto;width:640px;height:100%;padding:0 4px;border-radius:4px;scrollbar-width:thin;scrollbar-color:rgba(155,155,155,.5) transparent}.category-container li{transition:all .2s ease}.category-container li:hover{transform:translateY(-2px);box-shadow:0 4px 6px #0000001a}.content-container::-webkit-scrollbar{width:6px}.content-container::-webkit-scrollbar-track{background:transparent}.content-container::-webkit-scrollbar-thumb{background-color:#9b9b9b80;border-radius:4px;border:2px solid transparent}input[type=text],input[type=number],select,textarea{transition:all .2s ease}input[type=text]:focus,input[type=number]:focus,select:focus,textarea:focus{box-shadow:0 0 0 3px #3b82f680}.tooltip{transition:all .3s ease}.hover\:bg-gray-100:hover{--tw-bg-opacity: 1;background-color:rgb(243 244 246 / var(--tw-bg-opacity))}.hover\:text-gray-600:hover{--tw-text-opacity: 1;color:rgb(75 85 99 / var(--tw-text-opacity))}.hover\:opacity-80:hover{opacity:.8}.hover\:shadow-lg:hover{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.focus\:border-blue-500:focus{--tw-border-opacity: 1;border-color:rgb(59 130 246 / var(--tw-border-opacity))}.focus\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\:ring-blue-500:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(59 130 246 / var(--tw-ring-opacity))}@media (min-width: 640px){.sm\:text-sm{font-size:.875rem;line-height:1.25rem}}@media (min-width: 768px){.md\:mb-0{margin-bottom:0}.md\:me-4{margin-inline-end:1rem}}@media (prefers-color-scheme: dark){.dark\:bg-blue-600{--tw-bg-opacity: 1;background-color:rgb(37 99 235 / var(--tw-bg-opacity))}.dark\:text-gray-400{--tw-text-opacity: 1;color:rgb(156 163 175 / var(--tw-text-opacity))}}</style> 
 <div class="topmost">
  <div class="floating-ball">⚙️</div>

  <div class="main-container">

    <div class="panel hidden">
      <div class="toolbar">
        <span> ⚙️ </span>
        <button class="closeBtn">X</button>
      </div>
      <div class="panel-main h-full  ">

        <ul
          class="category-container flex-column space-y space-y-4 text-sm font-medium text-gray-500 dark:text-gray-400 md:me-4 mb-4 md:mb-0">
        </ul>
        <div class="content-container"></div>
      </div>
    </div>

  </div>
</div>`;
    
    shadowRoot.appendChild(root);
    document.body.appendChild(container);

    ((_root,_config,_cfg)=>{ try{(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const e of document.querySelectorAll('link[rel="modulepreload"]'))l(e);new MutationObserver(e=>{for(const o of e)if(o.type==="childList")for(const a of o.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&l(a)}).observe(document,{childList:!0,subtree:!0});function n(e){const o={};return e.integrity&&(o.integrity=e.integrity),e.referrerPolicy&&(o.referrerPolicy=e.referrerPolicy),e.crossOrigin==="use-credentials"?o.credentials="include":e.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function l(e){if(e.ep)return;e.ep=!0;const o=n(e);fetch(e.href,o)}})();let b,j,B;if(location.href.startsWith("http://localhost")){b=document;const r=Object.keys(win.scriptsdata)[0];j=win.scriptsdata[r].config,B=(t,n)=>(n!==void 0&&console.log(`${t}: Set to ${n}`),win.scriptsdata[r].cfg(t,n))}else b=_root,j=_config,B=_cfg;const{props:F,category:H}=j,h={mainContainer:b.querySelector(".main-container"),floatingBall:b.querySelector(".floating-ball"),panel:b.querySelector(".panel"),panelMain:b.querySelector(".panel-main"),toolbar:b.querySelector(".toolbar"),closeBtn:b.querySelector(".closeBtn"),categoryContainer:b.querySelector(".category-container"),contentContainer:b.querySelector(".content-container")};let P=new Map;const O=(r,t)=>r?r.style.display=t:null;let T=!1;async function I(r){const{floatingBall:t,ballToPanel:n,panel:l,panelMain:e}=h;T=r,r?l.classList.remove("hidden"):l.classList.add("hidden")}h.floatingBall.onclick=()=>I(!T);h.closeBtn.onclick=()=>I(!1);let M=!1,q,W,D,A;h.toolbar.addEventListener("mousedown",r=>{M=!0,q=r.clientX,W=r.clientY,D=h.mainContainer.offsetLeft,A=h.mainContainer.offsetTop,r.preventDefault()});b.addEventListener("mousemove",r=>{if(!M)return;const t=r.clientX-q,n=r.clientY-W;h.mainContainer.style.left=`${D+t}px`,h.mainContainer.style.top=`${A+n}px`});h.toolbar.addEventListener("mouseup",()=>{M=!1});function z(){let r=null;for(const t of H){const n=document.createElement("li");n.className="cursor-pointer inline-flex items-center px-4 py-3 text-white bg-blue-700 rounded-lg active w-full dark:bg-blue-600",n.id=`category-${t.key}-tab`,n.innerHTML=`<svg class="w-4 h-4 me-2 text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
                  <path d="M10 0a10 10 0 1 0 10 10A10.011 10.011 0 0 0 10 0Zm0 5a3 3 0 1 1 0 6 3 3 0 0 1 0-6Zm0 13a8.949 8.949 0 0 1-4.951-1.488A3.987 3.987 0 0 1 9 13h2a3.987 3.987 0 0 1 3.951 3.512A8.949 8.949 0 0 1 10 18Z"/>
        </svg>  <span>${t.display}</span>`;const l=document.createElement("div");l.className="content-container-item hidden",l.id=`content-${t.key}-container`,P.set(t.key,l),n.onclick=()=>{O(r,"none"),O(P.get(t.key),"block"),r=P.get(t.key)},h.contentContainer.append(l),h.categoryContainer.append(n)}}function K(r){const t=document.createElement("div");t.className="tooltip opacity-0 invisible absolute bg-gray-800 text-white text-xs rounded py-2 px-3 left-1/2 transform -translate-x-1/2 transition-opacity duration-300 z-10 whitespace-nowrap",t.style.bottom="calc(100% + 10px)",t.textContent=r;const n=document.createElement("div");return n.className="absolute left-1/2 transform -translate-x-1/2 -bottom-1",n.style.borderLeft="6px solid transparent",n.style.borderRight="6px solid transparent",n.style.borderTop="6px solid #1f2937",t.appendChild(n),t}function U(r){const t=document.createElement("p");return t.className="text-sm text-gray-600 mt-2 leading-relaxed",t.textContent=r,t}function E(r,t,n,l,e){const{display:o,description:a,tooltip:i}=l,s=document.createElement("div");s.className="bg-white p-4 rounded-lg shadow-md relative mb-6";const u=document.createElement("div");u.className="flex items-center justify-between mb-2";const y=document.createElement("label");y.className="text-sm font-medium text-gray-700 flex items-center";const c=document.createElement("span");if(c.textContent=o,y.appendChild(c),i){const p=document.createElement("span");p.className="ml-2 text-gray-400 hover:text-gray-600 cursor-help",p.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="16" x2="12" y2="12"></line><line x1="12" y1="8" x2="12.01" y2="8"></line></svg>';const d=K(i);p.appendChild(d),p.onmouseenter=()=>{d.classList.remove("opacity-0","invisible"),d.classList.add("opacity-100","visible")},p.onmouseleave=()=>{d.classList.add("opacity-0","invisible"),d.classList.remove("opacity-100","visible")},y.appendChild(p)}u.appendChild(y),u.appendChild(e),s.appendChild(u),a&&s.appendChild(U(a)),r.appendChild(s)}let S={note:(r,t,n,l)=>{const e=document.createElement("div");e.className="bg-blue-50 border-l-4 border-blue-500 text-blue-700 p-4 rounded-lg shadow-md mb-6 transition-all duration-300 hover:shadow-lg";const o=document.createElement("div");o.className="flex items-start";const a=document.createElement("div");a.className="flex-shrink-0 mr-3",a.innerHTML='<svg class="h-5 w-5" fill="currentColor" viewBox="0 0 20 20"><path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z" clip-rule="evenodd"></path></svg>';const i=document.createElement("div"),s=document.createElement("p");if(s.className="font-medium",s.textContent=l.display||"",i.appendChild(s),l.description){const u=document.createElement("p");u.className="text-sm mt-1",u.textContent=l.description,i.appendChild(u)}o.appendChild(a),o.appendChild(i),e.appendChild(o),r.appendChild(e)},bool:(r,t,n,l)=>{const e=document.createElement("div");e.className="flex items-center justify-between";const o=document.createElement("label");o.className="flex items-center cursor-pointer";const a=document.createElement("div");a.className="relative";const i=document.createElement("input");i.type="checkbox",i.className="sr-only",i.checked=t(n);const s=document.createElement("div");s.className=`block w-14 h-8 rounded-full transition-colors duration-300 ease-in-out ${i.checked?"bg-blue-600":"bg-gray-600"}`;const u=document.createElement("div");u.className=`absolute left-1 top-1 bg-white w-6 h-6 rounded-full transition-transform duration-300 ease-in-out ${i.checked?"translate-x-6":""}`,a.appendChild(i),a.appendChild(s),a.appendChild(u),o.appendChild(a),i.onchange=y=>{const c=y.target.checked;t(n,c),s.className=`block w-14 h-8 rounded-full transition-colors duration-300 ease-in-out ${c?"bg-blue-600":"bg-gray-600"}`,u.className=`absolute left-1 top-1 bg-white w-6 h-6 rounded-full transition-transform duration-300 ease-in-out ${c?"translate-x-6":""}`},e.appendChild(o),E(r,t,n,l,e)},option:(r,t,n,l)=>{const e=document.createElement("select");e.className="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block p-2.5 transition-all duration-300 ease-in-out hover:bg-gray-100",e.innerHTML=l.options.map(o=>`<option value="${o.key}">${o.display}</option>`).join(""),e.value=t(n),e.onchange=o=>t(n,o.target.value),E(r,t,n,l,e)},text:(r,t,n,l)=>{const e=document.createElement("input");e.type="text",e.className="bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block p-2.5 transition-all duration-300 ease-in-out hover:bg-gray-100",e.value=t(n),e.onchange=o=>t(n,o.target.value),E(r,t,n,l,e)},richtext:(r,t,n,l)=>{const e=document.createElement("textarea");e.className="bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 h-24 transition-all duration-300 ease-in-out hover:bg-gray-100",e.value=t(n),e.onchange=o=>t(n,o.target.value),E(r,t,n,l,e)},image:(r,t,n,l)=>{const e=document.createElement("div");e.className="flex flex-col space-y-2";const o=document.createElement("input");o.type="text",o.className="bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 transition-all duration-300 ease-in-out hover:bg-gray-100",o.placeholder="Enter image link or choose file",o.value=t(n)||"";const a=document.createElement("input");a.type="file",a.accept="image/*",a.className="block w-full text-sm text-gray-900 border border-gray-300 rounded-lg cursor-pointer bg-gray-50 focus:outline-none transition-all duration-300 ease-in-out hover:bg-gray-100";const i=document.createElement("img");i.className="max-w-xs max-h-48 object-contain rounded-lg shadow-md",i.src=t(n)||"",i.style.display=t(n)?"block":"none";const s=u=>{i.src=u,i.style.display=u?"block":"none",t(n,u)};o.onchange=u=>s(u.target.value),a.onchange=u=>{const y=u.target.files[0];if(y){const c=new FileReader;c.onload=p=>{s(p.target.result),o.value=p.target.result},c.readAsDataURL(y)}},e.append(o,a,i),E(r,t,n,l,e)},color:(r,t,n,l)=>{const e=document.createElement("div");e.className="flex space-x-2";const o=document.createElement("input");o.type="text",o.className="bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 transition-all duration-300 ease-in-out hover:bg-gray-100",o.placeholder="#000000",o.value=t(n)||"";const a=document.createElement("input");a.type="color",a.className="h-10 w-10 border-0 rounded cursor-pointer transition-all duration-300 ease-in-out hover:opacity-80",a.value=t(n)||"#000000";const i=s=>{o.value=s,a.value=s,t(n,s)};o.onchange=s=>{const u=s.target.value;/^#[0-9A-F]{6}$/i.test(u)&&i(u)},a.onchange=s=>i(s.target.value),e.append(o,a),E(r,t,n,l,e)},number:(r,t,n,l)=>{const e=document.createElement("input");e.type="number",e.className="bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block p-2.5 transition-all duration-300 ease-in-out hover:bg-gray-100",e.value=t(n),e.onchange=o=>t(n,parseFloat(o.target.value)),E(r,t,n,l,e)},tree:(r,t,n,l)=>{const e=document.createElement("div");e.className="flex flex-col space-y-2 p-2.5 w-full";const o=new Map,a={content:t(n)||[],get:c=>a.content.includes(c),add:c=>{a.content.includes(c)||(a.content.push(c),t(n,a.content))},remove:c=>{const p=a.content.indexOf(c);p!==-1&&(a.content.splice(p,1),t(n,a.content))}},i=(c,p=[],d=0)=>{const m=document.createElement("div"),x=d%2===1;m.className=`tree-node-container tree-node-${d}-container text-gray-900  ${x?"bg-gray-50":"bg-gray-200"}`;const v=document.createElement("span");let C="| ";for(let g=0;g<d;g++)C+=" --- ";v.textContent=C,m.appendChild(v);const f=document.createElement("input");f.type="checkbox",f.id=`tree-checkbox-${d}-${c.key}`;const k=document.createElement("label");k.htmlFor=f.id,k.textContent=c.title;const w=document.createElement("span");w.className="tree-toggle-icon cursor-pointer inline-flex items-center ml-2 w-4 h-4",w.textContent=c.children?"v":"⁕",w.addEventListener("click",()=>{const g=m.querySelector(".tree-children");if(g){g.classList.toggle("hidden");const N=g.classList.contains("hidden");w.textContent=N?"v":">"}}),m.appendChild(w),m.appendChild(v),m.appendChild(f),m.appendChild(k);const L=[...p,c.key],$=L.join(" > ");if(o.set($,{nodeContainer:m,checkbox:f}),f.checked=a.get($),f.addEventListener("change",g=>{const N=g.target.checked;a[N?"add":"remove"]($),c.children&&s(c.children,L,N),u(p)}),c.children&&!a.get($)){const g=document.createElement("div");g.classList.add("tree-children","hidden"),c.children.forEach(N=>{g.appendChild(i(N,L,d+1))}),m.appendChild(g)}else if(c.children){const g=document.createElement("div");g.classList.add("tree-children"),c.children.forEach(N=>{g.appendChild(i(N,L,d+1))}),m.appendChild(g)}return m},s=(c,p,d)=>{c.forEach(m=>{var f;const x=[...p,m.key],v=x.join(" > "),C=(f=o.get(v))==null?void 0:f.checkbox;C&&(C.checked=d,a[d?"add":"remove"](v)),m.children&&s(m.children,x,d)})},u=c=>{for(let p=c.length-1;p>=0;p--){const d=c.slice(0,p+1),m=d.join(" > "),x=o.get(m);if(x&&x.checkbox){const v=y(l.children,d);if(v&&v.children){const C=v.children.every(k=>{const w=[...d,k.key];return a.get(w.join(" > "))}),f=v.children.some(k=>{const w=[...d,k.key];return a.get(w.join(" > "))});x.checkbox.checked=C,x.checkbox.indeterminate=f&&!C,a[C?"add":"remove"](m)}}}},y=(c,p)=>{let d={children:c};for(const m of p)if(d=d.children.find(x=>x.key===m),!d)return null;return d};l.children.forEach(c=>{e.appendChild(i(c))}),E(r,t,n,l,e)}};function _(){try{if(settingCustomWidgets===void 0)return;for(const{type:r,creatorFunction:t}of settingCustomWidgets)S.hasOwnProperty(r)&&console.warn(`Widget type '${r}' already exists. It will be overwritten.`),S[r]=(n,l,e,o)=>{E(n,l,e,o,t(n,l,e,o))}}catch(r){console.error(`initCustomWidget: ${r}`),console.error("NOTE: CustomWidget only be applied in userscript.")}}function R(r,t,n){Object.entries(t).forEach(([l,e])=>{const o=r.querySelector(`#content-${e.category}-container`);if(o&&S[e.type])try{S[e.type](o,n,l,e)}catch(a){console.error(`generateSettingsUI: ${l}:${e}`,a)}else console.error(`generateSettingsUI: Can't find category ${e.category} or widget type ${e.type}`)})}_();z();R(b,F,B);h.floatingBall.click();_openConfigPanel=()=>h.floatingBall.click(); } catch(e){ console.error(e) }})(root,config,cfg);
}

// ad.js
addModule({
key: "ad", 
	// 广告屏蔽
	showInMenu: true,
	value: `@charset "UTF-8";.bili-video-card:has(svg.bili-video-card__info--ad),.feed-card:has(svg.bili-video-card__info--ad){display:none}#bannerAd,#slide_ad{display:none}`,
});

// beautify.js
addModule({
key: "beautify", 
	// (美化总开关)样式美化 & 自定义背景等
	pages: ["home"],
	showInMenu: true,
	value: () => {
		if (
			location.href === "https://www.bilibili.com/" &&
			get("beautify_work_on_index") === false
		)
			return;

		if (get("video_radius")) {
			style(`: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 #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}`);
		}
		if (get("background")) {
			style(`html,:root{--background:url(${get("background_value")})}`);
		}
		return `: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;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;box-shadow:1px 1px 4px 0#f5f5f5}: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 .bili-header__bar.mini-header,html body .bili-header__bar.mini-header{opacity:.98;backdrop-filter:blur(8px);background:rgba(255,255,255,.8)}: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 1px 4px 2px;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-video-card__image .v-img.bili-video-card__cover,:root body .bili-video-card__wrap .bili-video-card__image .v-img.bili-video-card__cover,html body .bili-live-card__wrap .bili-video-card__image .v-img.bili-video-card__cover,html body .bili-video-card__wrap .bili-video-card__image .v-img.bili-video-card__cover{border-radius:6px 6px 1px 1px}: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:.85;background-color:rgba(255,255,255,.65)!important;border-radius:0 0 6px 6px;transition:opacity .1s ease-in 0s}:root body #arc_toolbar_report:focus,:root body #arc_toolbar_report:hover,:root body .video-desc-container:focus,:root body .video-desc-container:hover,html body #arc_toolbar_report:focus,html body #arc_toolbar_report:hover,html body .video-desc-container:focus,html body .video-desc-container:hover{opacity:1}:root body .video-desc-container,html body .video-desc-container{padding:10px 8px 14px;margin:0;opacity:.68;transition:opacity .1s ease-in 0s}: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 .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 #viewbox_report,html body #viewbox_report{margin-bottom:16px;padding:2px;height:fit-content;transition:all .35s}:root body #viewbox_report:focus,:root body #viewbox_report:hover,html body #viewbox_report:focus,html body #viewbox_report:hover{box-shadow:1px -1px 6px 4px #f5f5f5;background-color:#f5f5f5;padding:4px;font-size:13px;border-radius:12px}:root body .video-info-container,html body .video-info-container{padding-top:4px;margin-top:20px}:root body .video-info-container .show-more,html body .video-info-container .show-more{display:none}:root body #bilibili-player-placeholder,html body #bilibili-player-placeholder{box-shadow:0-2px 4px 1px rgba(255,255,255,.1)}:root body #bilibili-player-placeholder #bilibili-player-placeholder-top,html body #bilibili-player-placeholder #bilibili-player-placeholder-top{background:0 0!important}`;
	},
});

// filter.js
addModule({
key: "filter", 
	// 评论过滤
	pages: ["video", "read"],
	showInMenu: true,
	value: (f) => {
		const rules = f.rules();
		const check = (x) => {
			try {
				// 获取回复内容元素
				const ctx = x.getElementsByClassName("reply-content")[0];
				// 如果已处理或内容为空则跳过
				if (x.classList.contains("🎇checked") || ctx.innerHTML === "") return;
				// 标记元素x已处理
				x.classList.add("🎇checked");
				// 如果回复内容文字长度大于限制(25)则跳过
				if (Number(ctx.outerText) > get("filter_length_limit", 25)) return;
				if (ctx.innerHTML !== "" && ctx.innerText === "") return;

				for (const r of rules) {
					if (r.test(x.getElementsByClassName("reply-content")[0].outerText)) {
						x.classList.add("🎇filtered");
						console.log(
							`已屏蔽: ${
								x.getElementsByClassName("reply-content")[0].outerText
							} \n 规则: ${r.toString()}`,
						);
						break;
					}
				}
			} catch (e) {
				x.classList.add("🎇checked");
			}
		};

		delay(
			() => {
				for (const x of document.getElementsByClassName("reply-item")) check(x);
				for (const x of document.getElementsByClassName("sub-reply-item"))
					check(x);
			},
			2000,
			{ loop: true },
		);

		return ".🎇filtered{display:none;}";
	},
	rules: () => {
		try {
			return get("filter_rules")
				.split("\n")
				.filter((x) => x.trim() !== "")
				.map((x) => {
					if (x.startsWith("/") && x.endsWith("/")) {
						return x.substring(1, x.length - 1);
					}
					return x;
				})
				.filter((x) => x.trim() !== "")
				.map((x) => new RegExp(x));
		} catch (error) {
			console.error(error);
			return [];
		}
	},
});

// hotkey.js
addModule({
key: "hotkey", 
	// 快捷键增强
	pages: ["video"],
	showInMenu: false,
	value: () => {
		// TODO 烂代码 需重构
		delay(
			() => {
				const img_view = document.querySelector(".reply-view-image");
				if (img_view === undefined) return;

				img_view.addEventListener("keydown", (e) => {
					if (e.key === "Escape")
						img_view.getElementsByClassName("close-container")[0].click();
					if (e.key === "a" || e.key === "ArrowLeft")
						img_view.getElementsByClassName("last-image")[0].click();
					if (e.key === "d" || e.key === "ArrowRight")
						img_view.getElementsByClassName("next-image")[0].click();
				});
			},
			1200,
			{ loop: true },
		);
	},
});

// quickly_copy.js
addModule({
key: "quickly_copy", 
	// 标题快捷复制
	pages: ["video"],
	showInMenu: true,
	value: {
		all: (feature) => {
			feature.fn(
				"[标题]链接",
				() =>
					`【${document.querySelector("h1.video-title").innerText}】\t${
						location.origin
					}${location.pathname}`,
			);
		},
		BV: (feature) => {
			feature.fn("BV", () => location.pathname.split("/")[2]);
		},
		url: (feature) => {
			feature.fn("链接", () => `${location.origin}${location.pathname}`);
		},
		title: (feature) => {
			feature.fn(
				"标题",
				() => `${document.querySelector("h1.video-title").innerText}`,
			);
		},
		off: null,
	},
	fn: (title, getText) => {
		delay(
			() => {
				const h1 = document.querySelector("h1.video-title");
				if (!h1) return;
				if (
					document.querySelector("h1.video-title").innerHTML.indexOf("🏷️") !== -1
				)
					return;

				const text = getText();
				const copy_btn = document.createElement("span");
				copy_btn.title = `复制当前视频的${title}:${text}`;
				copy_btn.style.cursor = "pointer";
				copy_btn.style.fontSize = "22px";
				copy_btn.innerText = "🏷️";
				copy_btn.addEventListener("click", () =>
					navigator.clipboard.writeText(text),
				);

				document.querySelector("h1.video-title").append(copy_btn);
			},
			2500,
			{ loop: true },
		);
	},
});

// remove_keyword_search.js
addModule({
key: "remove_keyword_search", 
	// TODO 失效?
	// 移除评论关键字搜索跳转(失效)
	pages: ["video", "read"],
	showInMenu: true,
	value: {
		icon: () => ".icon.search-word:{display:none;}",
		color: () =>
			".icon.search-word:{display:none;} .search-word a{color: #222!important;}",
		link: () => {
			delay(
				() => {
					const 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);
				},
				8000,
				{ loop: true },
			);
			return ".icon.search-word:{display:none;} .search-word a{color: #222!important;}";
		},
		off: null,
	},
});

// video_beautify.js
addModule({
key: "video_beautify", 
	// 首页视频样式美化
	pages: ["home"],
	showInMenu: true,
	value: `#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}`,
});

// video_cover_download.js
addModule({
key: "video_cover_download", 
	// 视频封面获取按钮
	pages: ["video"],
	showInMenu: true,
	value: () => {
		old_pic = "";
		delay(() => {
			setInterval(() => {
				if (!unsafeWindow.__INITIAL_STATE__) return;
				pic = unsafeWindow.__INITIAL_STATE__.videoData.pic;
				if (old_pic === pic) return;
				old_pic = pic;
				setTimeout(() => {
					const toolbar = document.querySelector(
						"#arc_toolbar_report .video-toolbar-right",
					);
					if (!toolbar) return;
					if (!toolbar.querySelector(".video-tool-more")) {
						// 等待加载完全 否则会出bug
						old_pic = "";
						return;
					}

					// biome-ignore lint/complexity/noForEach: <explanation>
					toolbar
						.querySelectorAll(".video-tool-getpic")
						.forEach((e) => e.remove());

					const btn = document.createElement("div");
					btn.className = "video-toolbar-right-item video-tool-getpic";
					btn.innerHTML = `<a class="video-toolbar-item-text" target="_blank" href="${pic}">获取封面</a>`;
					toolbar.insertBefore(btn, toolbar.firstChild);
				}, 300);
			}, 1800);
		}, 2500);
		return `.video-tool-getpic{margin-right:10px;color:var(--text3)}`;
	},
});

// video_live_recommand.js
addModule({
key: "video_live_recommand", 
	// 去除视频页直播推荐
	pages: ["video"],
	value: ".pop-live-small-mode{display:none;}",
});

// widescreen.js
addModule({
key: "widescreen", 
	// 视频页宽屏
	pages: ["video"],
	showInMenu: true,
	value: () => {
		function setSize() {
			// if (unsafeWindow.__INITIAL_STATE__) {
			//     var i = unsafeWindow.__INITIAL_STATE__.pageVersion,
			//         e = unsafeWindow.__INITIAL_STATE__.isPrVideo;
			//     "new_video" === i ? part1SetSize() : e && unsafeWindow.__INITIAL_STATE__.premiereInfo ? part1SetSize() : originSetSize()
			// } else originSetSize(),
			// 我也不知道上面的代码干什么用的,反正注释掉就正常了
			part1SetSize();
		}
		function constructStyleString(i, e) {
			for (let t = `${i} {`, n = Object.keys(e), o = 0; o < n.length; o++)
				t += `${n[o]}: ${e[n[o]]};`;
			return `${t}}\n`;
		}
		function part1SetSize() {
			// 是否宽屏
			const isWide = unsafeWindow.isWide;

			if (get("widescreen_hide_header_onWide")) {
				setTimeout(() => {
					try {
						document.querySelector(
							"#biliMainHeader .bili-header.fixed-header",
						).style.display = isWide ? "none" : "block";
					} catch (error) {
						console.error(error);
					}
				}, 50);
			}

			// 浏览器窗口高度
			const innerHeight = unsafeWindow.innerHeight;

			// 浏览器窗口宽度
			const innerWidth = Math.max(
				document.body?.clientWidth || unsafeWindow.innerWidth,
				1100,
			);

			// 右侧栏宽度
			const rightWidth = innerWidth > 1680 ? 411 : 350;

			// 计算主区域宽度
			const maxWidth = parseInt(
				(16 * (innerHeight - (innerWidth > 1690 ? 318 : 308))) / 9,
			);
			const mainWidth = innerWidth - 112 - rightWidth;
			let width = mainWidth < maxWidth ? mainWidth : maxWidth;

			width = Math.round(width * get("widescreen-width-times", 1.2));

			// 设置最小和最大宽度
			if (width < 668) {
				width = 668;
			}
			if (width > 1694) {
				width = 1694;
			}

			// 总宽度
			let totalWidth = width + rightWidth;

			// 计算高度
			let height;
			if (isWide) {
				totalWidth -= 125;
				width -= 100;
			}
			if (unsafeWindow.hasBlackSide && !isWide) {
				height =
					Math.round(
						(width - 14 + (isWide ? rightWidth : 0)) * (9 / 16) +
							(innerWidth > 1680 ? 56 : 46),
					) + 96;
			} else {
				height =
					Math.round((width + (isWide ? rightWidth : 0)) * (9 / 16)) +
					(innerWidth > 1680 ? 56 : 46);
			}

			// 主区域宽度
			const mainBoxWidth = totalWidth - rightWidth;

			// 生成设置样式的CSS
			const css =
				constructStyleString(".video-container-v1", {
					width: "auto",
					padding: "0 10px",
				}) +
				constructStyleString(".left-container", {
					width: `${mainBoxWidth}px`,
				}) +
				constructStyleString("#bilibili-player", {
					width: `${totalWidth - (isWide ? -30 : rightWidth)}px`,
					height: `${height}px`,
					position: isWide ? "relative" : "static",
				}) +
				constructStyleString("#oldfanfollowEntry", {
					position: "relative",
					top: isWide ? `${height + 28 - 18}px` : "0",
				}) +
				constructStyleString("#danmukuBox", {
					"margin-top": isWide ? `${height + 28}px` : "0",
				}) +
				constructStyleString("#playerWrap", {
					height: `${height}px`,
				}) +
				constructStyleString(".video-discover", {
					"margin-left": `${(totalWidth - rightWidth) / 2}px`,
				});
			setSizeStyle.innerHTML = css;
		}

		const set = () => {
			if (!unsafeWindow.setSizeStyle) {
				setTimeout(() => set(), 120);
				return;
			}

			unsafeWindow.setSize = setSize;

			setSize();
			setTimeout(setSize, 250);
			unsafeWindow.addEventListener("resize", () => {
				setSize();
			});
			unsafeWindow.PlayerAgent = {
				changed: true,
				player_widewin: () => {
					"new_video" === unsafeWindow.__INITIAL_STATE__.pageVersion &&
						unsafeWindow.scrollTo(0, 60);
					unsafeWindow.isWide = true;
					setSize();
				},
				player_fullwin: (i) => {
					unsafeWindow.scrollTo(0, 0);
					unsafeWindow.isWide = false;
					setSize();
				},
				toggleBlackSide: (i) => {
					unsafeWindow.hasBlackSide = i;
					setSize();
				},
			};
		};
		set();
	},
});
})();