夜间模式修复

修复Bilibili Evolved (Offline)-V1最后一个离线版的夜间模式

目前為 2022-05-27 提交的版本,檢視 最新版本

// ==UserScript==
// @name         夜间模式修复
// @namespace    http://tampermonkey.net/
// @version      1.0.2
// @description  修复Bilibili Evolved (Offline)-V1最后一个离线版的夜间模式
// @author       aotmd
// @match        https://www.bilibili.com/video/*
// @match        https://www.bilibili.com/medialist/play/*
// @match        https://t.bilibili.com/*
// @match        https://space.bilibili.com/*
// @match        https://live.bilibili.com/*
// @license MIT
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_deleteValue
// ==/UserScript==
(function () {
    let flag;
    let setting = {
        开始时间: '18:00',
        结束时间: '6:00'
    };
    if (GM_getValue('flag') !== undefined) {
        flag = GM_getValue('flag')
    } else {
        GM_setValue('flag', true);
        flag = true;
    }
    let styleElement = document.createElement('style');
    document.getElementsByTagName('head')[0].appendChild(styleElement);
    styleElement.appendChild(document.createTextNode(`
            /*视频播放页规则*/
            .v-wrap {background-color: #222!important; }
            .video-sections-content-list {background: black; }
            .video-episode-card__info.video-episode-card__info-playing {background-color: #6e6d6d!important; }
            .s_tag .tag-area .tag-item {background: #444!important; }
            /*动态页规则*/
            .bili-dyn-item, .bili-dyn-item div {
                background: #444;
                color: white;
                box-sizing: border-box;
            }
            .bili-dyn-content__orig.reference {
                background-color: #222;
                border: 2px solid;
            }
            .bili-dyn-title__text {
                color: white;
            }
            .bili-dyn-item {
                background: #444;
            }
            /*直播顶部修复*/
            div#head-info-vm {
                background-color: #444444!important;
            }
            `));
    if (flag) {
        styleElement["type"] = 'text/css';
    } else {
        styleElement["type"] = 'text';
    }
    window.setInterval(() => {
        if (new Date().getHours() >= new Date('1900/1/1 '+setting.开始时间).getHours()) {
            flag = true;
            styleElement["type"] = 'text/css';
        }
        if (new Date().getHours() < new Date('1900/1/1 '+setting.开始时间).getHours() &&
            new Date().getHours() >= new Date('1900/1/1 '+setting.结束时间).getHours()) {
            flag = false;
            styleElement["type"] = 'text';
        }
        GM_setValue('flag', flag);
    }, 1000);
    let a1 = document.createElement('button');
    a1.className = "gt1 button2";
    document.body.appendChild(a1);
    a1.innerText = "黑暗模式";
    a1.onclick = function () {
        flag = !flag;
        if (flag) {
            styleElement["type"] = 'text/css';
        } else {
            styleElement["type"] = 'text';
        }
        GM_setValue('flag', flag);
    };

    addStyle(`
    .gt1 {
        padding: 5px 5px;
        font-size: 14px;
        color: snow;
        position: fixed;
        border-radius: 4px;
        right: 5px;
        top: 10%;
        z-index: 999999;
        text-align: center;
        text-decoration: none;
        display: inline-block;
        margin: 4px 2px;
        -webkit-transition-duration: 0.4s;/* Safari */
        transition-duration: 0.4s;
        cursor: pointer;
        background-color: #4CAF50;
        border: 2px solid #4CAF50;
    }
    .gt1:hover {
        background-color: white;
        color: black;
    }
    .button2:hover {
        font-size: 14px;
        padding: 5px 10px;
        -webkit-transition: 0.5s;
        opacity: 1;
        margin: -3px 2px;
        right: 5px;
    }
    .button2 {
        padding: 0px;
        font-size: 12px;
        opacity: 0.2;
        right: -40px;
    }
    `);

    /**
     * 添加浏览器执行事件
     * @param func 无参匿名函数
     */
    function addLoadEvent(func) {
        let oldOnload = window.onload;
        if (typeof window.onload != 'function') {
            window.onload = func;
        } else {
            window.onload = function () {
                try {
                    oldOnload();
                } catch (e) {
                    console.log(e);
                } finally {
                    func();
                }
            }
        }
    }

    //添加css样式
    function addStyle(rules) {
        let styleElement = document.createElement('style');
        styleElement["type"] = 'text/css';
        document.getElementsByTagName('head')[0].appendChild(styleElement);
        styleElement.appendChild(document.createTextNode(rules));
    }
})();

QingJ © 2025

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