跳到正文

个人记录

深色模式插件

chenyuan3约 11 分钟
原文
文章信息与版本

文章信息

收录
2025年12月27日
更新
2026年5月22日
篇幅
约 11 分钟

版本

  1. v1当前
安装方式
  1. 下载 Microsoft Edge(推荐)或其他支持【扩展】功能的浏览器。接下来使用 Microsoft Edge 举例。
  2. 右上角三个点,找到【扩展】,点击【获取 Microsoft Edge 扩展】(即打开这个页面),搜索并下载篡改猴或暴力猴。接下来使用【篡改猴】举例。
  3. 找到【扩展】,点击【管理扩展】(即打开 edge://extensions/),打开【开发人员模式】。
  4. 找到【扩展】,找到刚才安装的【篡改猴】,点击【添加新脚本】,内容为接下来的源码。粘贴完后 Ctrl+S 即可完成安装。

安装过程中有任何问题欢迎私聊作者。

最新版源码
JavaScript
// ==UserScript==
// @name         点击切换浅色/深色模式
// @namespace    http://tampermonkey.net/
// @version      v0.0.3
// @description  点击切换浅色/深色模式
// @author       chenyuan3
// @match        https://www.luogu.com.cn/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=luogu.com.cn
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    window.addEventListener('load', () => {
        let x = document.createElement('div');
        x.innerHTML = '点击切换深色/浅色模式';
        x.id = 'extClicker-darkmode';
        document.getElementsByClassName('user-nav')[0].childNodes[0].before(x);
        let z = document.createElement('style');
        z.id = 'extStyle-darkmode';
        document.body.appendChild(z);
        z = document.createElement('style');
        z.id = 'extStyle-darkmode-usual';
        z.innerHTML = `
            #extClicker-darkmode:hover {
                cursor: pointer;
            }
        `;
        document.body.appendChild(z);
        x.onclick = () => {
            let y = document.getElementById('extStyle-darkmode');
            if (y.innerHTML === '') {
                y.innerHTML = `
                    * {
                        color: white;
                        background-color: black !important;
                    }

                    .lfe-h2, .lfe-h3 {
                        color: white !important;
                    }

                    .right .user-nav sup {
                        background-color: rgb(231, 76, 60) !important;
                    }

                    ${location.href === 'https://www.luogu.com.cn/problem/list' ? `
                        div.square {
                            background-color: var(--lfe-color--primary) !important;
                        }

                        .l-card .title.no-wrap {
                            color: white !important;
                        }
                    ` : ""}
                `;
            } else {
                y.innerHTML = '';
            }
        };
    });
})();

深色模式插件。不保证对旧前端使用的效果。使用时右上角会出现“ 点击切换深色/浅色模式”。点击使用。

以下是新前端页面的支持情况:

如有遗漏请私聊作者补充。已完成的页面如果出现问题也请私聊作者提出 bug。

更新日志

v0.0.3

解决了铃铛数量和私信数量在深色模式的显示问题。

v0.0.2

支持题库。

v0.0.1

基础版本。

原文