【伟哥自用】ZeroClaw 文档 强制浅色(去黑底刺眼主题)

Created 20 days ago
Updated 20 days ago
docs.zeroclawlabs.ai 是 mdBook 套了一层自研 pc-* 主题,默认 default-dark(近黑底 + 刺眼青/紫字)。本脚本只用 GM_addStyle 注入 CSS,把暗色变量盖成浅色——不动 html 的主题 class、不用 observer(实测这站是整页跳转,userscript 每次加载都会重跑,无需重注入)。配色直接照搬站点自带的 default-light 调色板,所以代码高亮、侧栏、搜索、表格、引用块、mermaid 图会全部跟着变量自动变浅,零生硬硬编码。
#CSS Theme Override
#Documentation Site
#Theme Customization
Statistics
Total Installs
12
Last 24h
+0
User Rating
-
强制将 ZeroClaw 文档站点的暗色主题替换为原生浅色主题的 CSS 覆盖脚本

ZeroClaw Docs — Force Light Theme

A Tampermonkey/Violentmonkey userscript that forces docs.zeroclawlabs.ai into a normal, white-background light theme.

The site ships locked to a default-dark theme (near-black #1e1e24 background with a high-contrast cyan accent) that is genuinely hard to read for long sessions. This script overrides it with the site's own default-light palette, so the result looks native and intentional rather than like a hacked-on reskin.

Companion to a.js (the same idea for robustmq.com). Same playbook, adapted to mdBook.


Install

  1. Install a userscript manager: Tampermonkey or Violentmonkey.
  2. Open zeroclaw-docs-light.user.js in the manager (drag it in, or click Create new and paste the contents).
  3. Visit any docs.zeroclawlabs.ai page. The dark flash is gone before first paint.

@match https://docs.zeroclawlabs.ai/* covers every version path (/v0.8.3/…) and locale (/en/, /zh-CN/, /ja/, …).


Configure the accent

At the top of the script:

const BRAND = '#0891b2'; // native default-light accent

Change that one line to recolor links, inline code, the active sidebar item, quote borders, search highlights, and mermaid diagram nodes — the full accent family is derived from it via the shade() / rgba() / triplet() helpers. A few options:

BRAND Look
#0891b2 native cyan (default)
#2563eb blue
#4f46e5 indigo
#7c3aed purple
#16a34a green

When BRAND equals the native value, the derivation block is skipped entirely, so the default install is byte-for-byte the site's own light theme.


How it works

The docs are mdBook reskinned with a custom --pc-* design system. Critically, every visual surface — code highlighting, tables, search results, blockquotes, mermaid diagrams — is bridged onto --pc-* via var(). That means overriding the base variables is enough; everything downstream follows automatically.

  • @run-at document-start + GM_addStyle — injects the override before first paint (no dark flash). It also runs before mermaid-init.js, which reads --color-scheme / --pc-* at load time to pick diagram colors — so diagrams render light too.
  • html:not(#_){ --x: … !important } — the :not(#_) raises specificity to beat the per-theme html.<theme-id>{} rules in pc-themes.css, and !important guarantees the win. The site's theme variables are not marked !important, so this is decisive.
  • No class-stripping, no observers. The site does full page reloads on navigation (verified: an injected window marker does not survive a chapter click), so the userscript re-runs on every load by itself. No MutationObserver, no jank.

The only hardcoded colors in the site's reskin are a few black box-shadow values, which look correct (better, even) on a light background — so nothing else needs patching.


Verified

Tested live against request-lifecycle.html (inline code, <pre> blocks, and four mermaid diagrams) by injecting the exact stylesheet and reading computed styles:

Surface Result
Page / body text #f4f4f5 bg, #18181b text
Sidebar / menu bar white bg, dark text
Inline code #06b6d4 accent on soft tint
<pre> block light bg, dark text
Mermaid diagrams node stroke #0891b2 (light accent), dark text

Scope / non-goals

  • Only touches docs.zeroclawlabs.ai.
  • Does not modify content, navigation, or the theme-switcher UI — it just wins the variable cascade. The built-in theme picker still works; this script simply re-asserts light on every load.
  • Status colors (--pc-status-success, etc.) are left as-is; they're vivid by design and used for small badges, not body text. Tweak them in the variable block if you want.
Script Details
Applicable Sites
License
Not declared
No license declared — reuse with caution