🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

YouTube to Bilibili Style

油管爆改哔哩哔哩:将YouTube的标签页图标、logo替换为哔哩哔哩的,修改进度条颜色,并将标题中的"YouTube"替换为"哔哩哔哩"。

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

You will need to install an extension such as Tampermonkey to install this script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

// ==UserScript==
// @name         YouTube to Bilibili Style
// @namespace    http://tampermonkey.net/
// @version      1.9
// @description  油管爆改哔哩哔哩:将YouTube的标签页图标、logo替换为哔哩哔哩的,修改进度条颜色,并将标题中的"YouTube"替换为"哔哩哔哩"。
// @author       BlingCc (Modified by Gemini)
// @match        https://www.youtube.com/*
// @grant        none
// @icon         https://www.google.com/s2/favicons?sz=64&domain=YouTube.com
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';

    // Bilibili Logo SVG
    const logoSvg = '<svg viewBox="0 0 2186.86 999.65" xmlns="http://www.w3.org/2000/svg" style="width: 96px; height: 28px;"> <path fill="#06AEEC" d="M2030.61,892.82c-9.77,0-18.55,0-26.37-0.98c-16.6-0.97-33.2-1.95-49.8-1.95c-10.74,0-10.74,0-11.72-10.74 l-15.63-177.74l-15.62-147.46l-10.74-90.82l-9.77-79.1l-17.58-123.05c-5.86-43.94-12.69-86.91-21.48-130.86 c-0.98-6.83-0.98-7.81,6.84-8.79c30.27-5.86,61.52-8.79,92.77-8.79h10.74c4.88,0.98,7.81,3.91,8.79,9.77l3.91,67.38l27.34,364.26 l13.67,166.99l8.79,95.71L2030.61,892.82L2030.61,892.82z M833.34,112.54h17.58c8.79,0,10.74,2.93,10.74,11.72l7.82,118.17 l17.58,245.11l10.74,127.93l7.81,98.64l15.63,169.92c0,7.81-0.98,8.79-8.79,8.79l-70.32-2.93c-4.88,0.98-7.81-1.95-7.81-6.84 l-2.93-34.18c-2.93-29.29-5.86-58.59-7.81-88.86l-15.63-154.3l-16.6-139.65l-11.72-98.63l-12.69-89.85 c-5.86-40.04-12.7-81.05-19.53-121.09l-4.89-27.34c-0.97-4.89,0-6.84,4.89-7.82C774.75,116.45,801.12,111.57,833.34,112.54 L833.34,112.54L833.34,112.54z M1815.77,506.1c24.41,0,27.34,0.98,31.25,24.41c4.88,29.3,8.79,58.6,11.72,87.89l10.74,94.73 l20.51,201.17c0.97,4.89,0,6.84-4.89,6.84l-76.17,8.79c-7.81,0.97-9.77,0-10.74-7.81l-43.95-224.61l-27.34-149.42l-3.91-20.51 c-0.97-3.9,0.98-6.83,4.89-7.81C1758.15,512.94,1787.45,508.05,1815.77,506.1L1815.77,506.1L1815.77,506.1z M705.41,506.1 c26.37-0.98,29.3,1.95,32.23,26.37c6.84,40.04,11.72,79.1,15.63,119.14l12.69,117.18l7.81,79.11l6.84,63.47 c0,8.79-0.98,10.75-8.79,11.72l-72.26,6.84c-7.82,0.97-9.77,0-10.75-7.81l-59.57-306.65l-15.62-86.91 c-0.98-4.88,0.97-7.81,5.86-8.79C649.75,512.94,678.07,508.05,705.41,506.1L705.41,506.1L705.41,506.1z M1078.46,808.83v121.1v3.9 c0.98,5.86-1.95,8.79-7.81,7.82h-23.44c-16.6,0-33.2,0.97-49.8,1.95c-8.79,0.98-9.77,0.98-10.75-9.77l-15.62-175.78l-7.81-86.91 l-11.72-132.81c-0.98-10.75,0.98-12.7,9.76-13.68c27.35-2.93,54.69-2.93,82.04-1.95l20.5,2.93c7.82,2.93,8.79,3.91,8.79,11.72 l2.93,52.73l0.98,58.6C1077.49,702.39,1078.46,755.12,1078.46,808.83L1078.46,808.83L1078.46,808.83z M2186.86,814.69v114.26v5.86 c0,4.88-1.95,7.81-6.84,6.84h-35.15c-13.67,0-27.35,0.97-40.04,1.95c-7.81,0.98-8.79,0-9.77-8.79l-20.5-228.52l-10.75-113.28 l-3.9-57.61c-0.98-7.82,0.97-9.77,8.79-9.77c32.22-3.91,65.43-4.88,97.65-0.98c12.7,0.98,14.65,4.89,15.63,17.58l2.93,129.88 L2186.86,814.69L2186.86,814.69z M1787.45,298.09c9.76,0,18.55,0.98,25.39,1.95c4.88,0.98,6.83,2.93,7.81,7.82l12.69,135.74 c2.93,11.72,0.98,13.67-10.74,13.67l-33.2,1.95c-6.84,0.98-9.77,1.96-9.77-8.78l-13.67-110.36l-3.9-31.25 c-0.98-5.86,0.97-8.79,6.83-9.76L1787.45,298.09L1787.45,298.09z M681,298.09c7.81,0,15.63,0.98,22.46,1.95 c3.91,0.98,5.86,2.93,6.84,7.82l3.9,34.18l9.77,106.44c0.98,7.81,0.98,8.79-6.84,8.79l-38.08,1.95c-7.81,0.98-8.79,0-9.77-7.81 l-8.79-78.12l-7.81-65.43c-0.98-4.89,0.98-7.82,5.86-7.82C665.38,299.07,673.19,298.09,681,298.09L681,298.09L681,298.09z  M1070.65,395.75v67.38c0.98,10.74-0.98,10.74-9.77,10.74c-12.69,0-24.41-0.97-36.13-1.95c-7.81-0.98-8.79-0.98-7.81-8.79 l-2.93-83.01c0-18.55,0-37.11-0.98-55.66c-0.97-8.79,0-9.77,8.79-9.77c13.67,0,27.34,0.98,41.02,2.93c7.81,0,7.81,1.96,7.81,9.77 V395.75L1070.65,395.75z M2180.02,396.72v67.39c0,8.79-0.97,9.76-9.76,9.76l-37.11-1.95c-5.86-0.98-8.79-3.91-7.81-8.79 l-2.93-139.65c0-7.81,0.97-8.79,8.79-8.79c12.69,0,24.41,0.98,36.13,1.96c14.65,0.97,12.69,3.9,12.69,14.64L2180.02,396.72 L2180.02,396.72z M650.73,449.46c0.97,11.72,0,13.67-11.72,14.65l-23.44,5.86c-7.81,2.93-8.79,0.97-9.76-5.86l-24.42-137.7 c-2.93-8.79-0.98-10.74,7.81-11.72l34.18-5.86c7.82-0.97,9.77-0.97,9.77,6.84c2.93,16.6,5.86,33.2,7.81,49.8l9.77,78.13 L650.73,449.46L650.73,449.46z M1689.79,315.67c14.65-2.93,30.27-4.88,45.9-6.84c4.88-0.97,6.83,1.96,7.81,6.84l7.81,53.71 c3.91,26.37,6.84,52.73,7.82,79.1v7.81c0.97,3.91-0.98,6.84-4.89,7.82l-31.25,6.83c-4.88,0.98-6.83-0.97-7.81-5.86l-25.39-145.5 V315.67L1689.79,315.67z M996.43,421.14c0,15.62-0.98,30.27-1.95,43.94c0,4.89-1.96,6.84-6.84,7.82l-30.27,2.93 c-4.88,0.97-6.84-1.96-6.84-6.84c-1.95-14.65-2.93-28.32-3.9-42.97c-1.96-26.37-3.91-53.71-4.89-81.05l-1.95-19.53 c-0.98-3.91,0.98-5.86,4.88-5.86l40.04-2.93c6.84,0,8.79,0.97,8.79,8.79L996.43,421.14L996.43,421.14z M2103.85,405.51 c0.98,18.56,0.98,38.09,0,56.64c0.98,8.79-0.97,10.75-9.76,10.75l-27.35,2.93c-4.88,0.97-7.81-1.96-7.81-6.84 c-0.98-24.41-2.93-49.8-4.88-74.22l-3.91-68.36c-0.98-4.88,0.98-6.83,4.88-6.83l39.07-2.93c6.83,0,7.81,0.97,7.81,8.79 C2103.85,351.8,2104.83,379.15,2103.85,405.51L2103.85,405.51L2103.85,405.51z M612.64,738.52c15.63,18.56,18.56,39.06,11.72,61.52 c-5.86,21.49-16.6,40.04-32.23,55.67c-25.39,26.37-54.68,47.85-86.91,64.45c-55.66,29.3-113.28,49.81-174.81,60.55 c-43.94,8.79-87.89,14.65-131.83,17.58c-13.67,0.97-27.34,0.97-41.02,0.97h-29.29c-7.82,0-9.77-1.95-10.75-9.76l-6.83-94.73 L92.13,708.25l-20.5-177.74l-11.72-94.72l-12.7-90.82c-6.83-49.81-15.62-99.61-24.41-149.42C15.96,155.51,9.13,115.47,0.34,75.44 c-0.98-4.89,0-8.79,4.88-9.77L140.96,9.03c8.79-3.91,16.6-6.84,25.39-8.79c5.86-0.98,8.79,0.98,7.81,6.84 c0,15.62,0,31.25-0.97,47.85l-0.98,12.69c-0.97,56.64-0.97,113.28,0,170.9c0.98,49.81,3.91,100.59,6.84,150.39 c4.88,78.13,12.69,156.25,20.51,233.4c0,7.81,0.97,7.81,9.76,6.84c16.6-2.93,32.23-3.91,48.83-3.91 c51.76,0,103.51,5.86,153.32,18.55c43.94,10.75,85.94,25.4,127.93,43.95c20.51,9.77,39.06,21.48,56.64,35.16 C602.88,727.78,607.76,732.66,612.64,738.52L612.64,738.52L612.64,738.52z M1713.23,729.73c20.51,16.6,27.34,39.06,21.48,65.43 c-4.88,21.49-14.65,40.04-29.3,56.64c-23.43,26.37-50.78,46.88-81.05,63.48c-58.59,32.23-121.09,54.69-187.5,66.41 c-36.13,6.83-72.27,12.69-108.4,15.62c-20.51,1.95-42.97,2.93-65.43,1.95h-26.37c-5.85,0.98-8.78-1.95-8.78-7.81 c-1.96-27.34-3.91-54.69-6.84-82.03l-15.63-166.99l-16.6-145.51l-20.5-164.06c-2.93-28.32-6.84-57.62-11.72-85.94l-17.58-109.38 c-7.81-51.75-17.58-103.51-28.32-155.27l-0.98-6.83c-1.95-4.89,0-8.79,4.88-9.77c47.86-19.53,94.73-41.02,142.58-59.57 c12.7-4.88,28.32-10.74,27.35,0.98c-3.91,36.13-2.93,72.26-3.91,107.42c-0.98,29.29-0.98,58.59,0.98,86.91v22.46 c0,35.16,0.97,70.32,3.9,104.49c1.96,45.9,4.89,92.78,8.79,138.68l8.79,98.63c0.98,18.55,2.93,36.13,5.86,54.69 c0,10.74,1.95,9.76,10.74,8.79c17.58-2.93,35.16-3.91,52.74-3.91c61.52,0.98,121.09,10.74,179.68,27.34 c40.04,10.75,78.13,25.39,115.24,44.93C1683.93,706.29,1698.58,717.04,1713.23,729.73L1713.23,729.73L1713.23,729.73z  M301.12,901.61c14.65-8.79,40.04-26.37,75.19-53.71c35.16-28.32,56.64-46.88,65.43-56.64c-52.73-23.44-107.42-43.95-164.06-62.5 L301.12,901.61L301.12,901.61z M1548.19,796.14c2.93-2.93,1.95-4.88-0.98-6.84l-23.44-9.76c-41.01-17.58-82.03-33.21-124.02-46.88 l-5.86-1.95c-1.95-0.98-3.9,0-6.83,0.98l23.43,168.94c2.93,0,4.89-0.98,5.86-1.95c38.09-27.35,76.17-55.67,114.26-85.94 L1548.19,796.14L1548.19,796.14z" /> </svg>';
    const bilibiliFavicon = 'https://www.bilibili.com/favicon.ico';

    /**
     * 注入自定义CSS样式来修改颜色
     */
    function injectCustomStyles() {
        const styleId = 'bilibili-style-injector';
        // 如果样式已经注入,则不再重复执行
        if (document.getElementById(styleId)) {
            return;
        }

        const css = `
            :root {
                --yt-spec-static-brand-red: #05A3D7 !important;
            }

            .ytp-play-progress.ytp-swatch-background-color, .ytp-play-progress {
                background: #05A3D7 !important;
            }

            .ytProgressBarPlayheadProgressBarPlayheadDot, .ytProgressBarLineProgressBarPlayed{
                background: #05A3D7 !important;
            }

            /* 进度条已播放部分 */
            .ytp-play-progress.ytp-swatch-background-color {
                background: #05A3D7 !important;
            }

            .ytp-volume-slider-handle::before{
                background:linear-gradient(to right,#05A3D7 50%,#fff 100%) !important;
            }

            /* 去除拖动圆点周围的白色边框,使其更融合 */
            .ytp-scrubber-button {
                border: none !important;
            }
            .ytp-settings-button.ytp-hdr-quality-badge::after {
                border-color: #05A3D7 !important;
            }

            .ytp-settings-button.ytp-hd-quality-badge::after, .ytp-settings-button.ytp-hdr-quality-badge::after, .ytp-settings-button.ytp-4k-quality-badge::after, .ytp-settings-button.ytp-5k-quality-badge::after, .ytp-settings-button.ytp-8k-quality-badge::after, .ytp-settings-button.ytp-3d-badge-grey::after, .ytp-settings-button.ytp-3d-badge::after {
                background-color: #05A3D7 !important;
            }

            .ytThumbnailOverlayProgressBarHostWatchedProgressBarSegment{
                background: #06AEEC !important;
            }

            #progress.ytd-thumbnail-overlay-resume-playback-renderer {
                background: #06AEEC !important;
            }

            #progress.yt-page-navigation-progress {
                background:linear-gradient(to right,#05A3D7 80%,#06AEEC 100%) !important;
            }

            .ytp-chrome-controls .ytp-button[aria-pressed]::after{
                background-color: #05A3D7 !important;
            }

            .ytp-menuitem[aria-checked=true] .ytp-menuitem-toggle-checkbox {
                background: #06AEEC !important;
            }

        `;

        const style = document.createElement('style');
        style.id = styleId;
        style.textContent = css;
        document.head.appendChild(style);
    }


    /**
     * 替换网站图标 (Favicon)
     */
    function changeFavicon() {
        let link = document.querySelector("link[rel~='icon']");
        if (link && link.href !== bilibiliFavicon) {
            link.href = bilibiliFavicon;
        } else if (!link) {
            link = document.createElement('link');
            link.rel = 'icon';
            link.href = bilibiliFavicon;
            document.head.appendChild(link);
        }
    }

    /**
     * 替换 Logo
     */
    function changeLogo() {
        const logoElement = document.querySelector('#logo-icon');
        if (logoElement && !logoElement.classList.contains('bili-logo-replaced')) {
            logoElement.innerHTML = logoSvg;
            logoElement.classList.add('bili-logo-replaced');
        }
    }

    /**
     * 替换标题
     */
    function changeTitle() {
        // 使用正则表达式 /youtube/gi 进行全局、不区分大小写的替换
        if (document.title.toLowerCase().includes('youtube')) {
            document.title = document.title.replace(/youtube/gi, '哔哩哔哩 (゜-゜)つロ 干杯~~bilibili');
        }
    }

    /**
     * 执行所有动态修改(会被重复调用)
     */
    function applyDynamicChanges() {
        changeFavicon();
        changeLogo();
        changeTitle();
    }

    // --- 脚本执行入口 ---

    // 1. 立即注入样式,这是最优先的
    injectCustomStyles();

    // 2. 初始执行所有修改
    applyDynamicChanges();

    // 3. 使用 MutationObserver 来监控DOM变化,确保在YouTube动态加载内容后脚本依然生效
    const observer = new MutationObserver(applyDynamicChanges);
    observer.observe(document.documentElement, {
        childList: true,
        subtree: true,
    });

    // 4. 专门监控标题变化
    const titleObserver = new MutationObserver(changeTitle);
    const titleElement = document.querySelector('title');
    if (titleElement) {
        titleObserver.observe(titleElement, { childList: true });
    }
})();