Greasy Fork

Greasy Fork is available in English.

讨论区颜色自定义

可以更改源代码,设置洛谷各个讨论区的颜色

当前为 2023-09-09 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name          讨论区颜色自定义
// @namespace     https://www.luogu.com.cn/user/542457
// @description   可以更改源代码,设置洛谷各个讨论区的颜色
// @author        cff_0102
// @run-at        document-end
// @version       0.1.0.2
// @license       MIT
// @match         https://www.luogu.com.cn/*
// @icon          https://cff.flarum.cloud/assets/favicon-79dxszv4.png
// ==/UserScript==

(function() {
    'use strict';

    // 定义颜色更改函数
    function changeColors() {
        const a = document.querySelectorAll("[title=全部板块]");
        for (let el of a) {
            el.style.cssText = "--forum-color: #34495e; color: var(--forum-color);"; //洛谷蓝
        }
        const b = document.querySelectorAll("[title=站务版]");
        for (let el of b) {
            el.style.cssText = "--forum-color: #8e44ad; color: var(--forum-color);"; //紫名紫
        }
        const c = document.querySelectorAll("[title=题目总版]");
        for (let el of c) {
            el.style.cssText = "--forum-color: #52c41a; color: var(--forum-color);"; // AC 绿
        }
        const d = document.querySelectorAll("[title=学术版]");
        for (let el of d) {
            el.style.cssText = "--forum-color: #e74c3c; color: var(--forum-color);"; //红名红
        }
        const e = document.querySelectorAll("[title=灌水区]");
        for (let el of e) {
            el.style.cssText = "--forum-color: #3ba4a4; color: var(--forum-color);"; //cff 青
        }
        const f = document.querySelectorAll("[title=反馈、申请、工单专版]");
        for (let el of f) {
            el.style.cssText = "--forum-color: #f39c11; color: var(--forum-color);"; //排行橙
        }
        const g = document.querySelectorAll("[title=小黑屋]");
        for (let el of g) {
            el.style.cssText = "--forum-color: #996600; color: var(--forum-color);"; //棕名棕
            const svgElement = el.querySelector("svg");
            const pathElement = svgElement.querySelector("path");
            pathElement.setAttribute("d", "M400 32H48C21.5 32 0 53.5 0 80v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48"); //更改小黑屋图标(从四个方块改成一个方块)
        }
    }

    //每隔 500 毫秒执行一次颜色更改函数
    setInterval(changeColors, 514);
})();