【伟哥自用】LavinMQ 文档 强制浅色(去黑底)

建立於 9 小時前
更新於 9 小時前
lavinmq.com 文档站天生是暗色设计(Tailwind 硬编码黑底,无主题切换、无浅色模式)。本脚本用 GM_addStyle 把那套暗色调色板原地盖成浅色,纯 CSS、不动任何类、不卡页面。代码块保留站点原有的暗色 Monokai 高亮(可读)。
#样式美化
#LavinMQ
#主题切换
資料統計
總安裝量
1
今日新增
+1
使用者評分
-
为 LavinMQ 文档站点强制应用浅色主题的 CSS 覆盖脚本

LavinMQ Docs — Light Theme (Userscript)

lavinmq.com docs are dark by design — Tailwind with hardcoded black backgrounds, no theme toggle, and no light mode at all. This script fabricates a light version: white background, dark text, normal readability.

  • Single-file script: lavinmq-light-theme.user.js
  • Current version: 1.0.0
  • Scope: *://lavinmq.com/*, *://*.lavinmq.com/*

Why it's needed

The LavinMQ docs are built with Tailwind CSS, and the dark look is baked directly into utility classes, e.g.:

<body class="bg-[#141414]">          <!-- near-black page background -->
.lmq-docs h1, .lmq-docs h2 { color: #FAFAFA; }   /* near-white headings */
.lmq-docs p,  .lmq-docs ul { color: #D9D6CE; }   /* light-grey body text */

There's no .dark class, no data-theme attribute, no toggle — the site is simply dark, with no light mode to switch to. So the only way is to override its palette.


How it works (and why it won't freeze the page)

The script does nothing but inject one CSS block via GM_addStyle — no observers, no polling, no class toggling:

  1. Every selector is prefixed with html:not(#_) to max out specificity, so with !important it reliably beats Tailwind utilities and the .lmq-docs nested rules;
  2. It uses attribute selectors like [class~="bg-[#141414]"] to match Tailwind arbitrary-value classes (no need to escape []#), recoloring the dark palette in place;
  3. It additionally overrides the .lmq-docs nested text colors for body/headings/tables.

Pure CSS end to end — no DOM listening, no class mutation, so it can't freeze the page (a lesson learned from the RobustMQ script's v1 freeze bug).


Coverage

Element Result
Page / navbar / sidebar background White / light grey
Body text, lists, tables Dark grey text #3c3c43
Headings H1–H6 Dark #1f2430
Borders / dividers Light grey #e2e2e3
Inline code Blue-grey text #476582 + light pill
Links Readable dark green #15803d (original #54BE7E was too pale)
Code blocks Kept as the site's dark Monokai highlighting (see below)

A key trade-off: code blocks stay dark

The site's code blocks use Rouge + a dark Monokai theme (figure.highlight with #262626 background, near-white/pink tokens), tuned for a dark surface. The script intentionally does not flip them light — doing so would make the light tokens invisible on a light background. Dark code blocks on a light doc are common (GitHub et al.), and they stay perfectly readable as-is. Only inline code is restyled as a light pill.


Install

  1. Install the Tampermonkey browser extension;
  2. Either:
    • Drag lavinmq-light-theme.user.js into your browser and confirm in the prompt;
    • or open the Tampermonkey dashboard → Create a new script → paste the file contents → save;
  3. Open lavinmq.com and reload.

To restore the original dark look, disable the script in Tampermonkey and reload.


Customize the palette

There's a config block at the top of the script — just change the constants:

const BG = '#ffffff';                       // page / navbar background
const BG_ALT = '#f6f6f7';                   // sidebar / secondary surface (replaces #2f2f2f)
const BG_TER = '#ececee';                   // tertiary surface (replaces #414040)
const TEXT = '#3c3c43';                     // body text
const HEAD = '#1f2430';                     // heading text
const MUTED = '#67676c';                    // muted text
const BORDER = '#e2e2e3';                   // borders / dividers
const CODE_COLOR = '#476582';               // inline-code text color
const CODE_BG = 'rgba(101, 117, 133, .14)'; // inline-code background
const LINK = '#15803d';                     // link color (set 'keep' to preserve the original mint #54BE7E)

Known limitations / extending

  • The script targets the site's current Tailwind palette. If LavinMQ redesigns and changes its color classes, add a line in the same format:
    html:not(#_) [class~="new-dark-class-name"]{ background-color:#fff !important; }
    
    To find class names: open DevTools (F12), select the element, and look at the bg-[#xxxxxx] / text-[#xxxxxx] tokens in its class.
  • If a stray dark element slips through (an icon, a badge), add one more rule as shown above.

Version history

Version Notes
1.0.0 Initial; overrides the Tailwind dark palette + .lmq-docs nested text rules; inline code → light, code blocks kept as dark Monokai
腳本詳情
授權協議
未宣告
未宣告協議,他人引用需謹慎