How to Extract a Real DESIGN.md and Tailwind v4 @theme from Supported Webpages (Zero <all_urls> MV3)

Inside SpecPeek v1.0.1: zero passive content_scripts, a closed Shadow DOM on <html>, separate CIE Lab and OKLCH conversion paths, deterministic local Tailwind conversion with no LLM, current-page DESIGN.md and W3C DTCG exports, and CSS-pixel overlay calibration.

Before and after diagram: filtering 300+ noisy getComputedStyle() properties into 61 curated CSS rules, Tailwind v4 @theme tokens, and DESIGN.md locally with zero all_urls
SpecPeek v1.0.1 (135 KiB CWS upload ZIP · 0 runtime npm dependencies): four local-first subsystems running on demand.

Install three popular Chrome CSS inspectors and open chrome://extensions immediately afterward. Almost every one of them asks for "Read and change all your data on all websites" (<all_urls> or *://*/*) and registers a passive content_scripts entry that boots inside every tab you open—including your bank, your email, and your production admin dashboards.

You only need a CSS inspector on the single tab you are actively debugging. There is no technical reason for a hover HUD to execute code on background tabs you never clicked it on.

When I built SpecPeek for hover inspection, code export, design handoff and pixel-overlay QA, I shipped v1.0.1 as a 135 KiB Chrome Web Store upload ZIP (138,207 B); the signed CRX is 69.6 KiB (71,297 B). Unpacked core JavaScript totals about 110.6 KB: background.js is 23.4 KB, content.js is 84.8 KB, and license-page.js is 2.3 KB. The license page also has 1.7 KB of HTML and 1.4 KB of CSS. There are zero runtime npm dependencies (extension/package.json has devDependencies only).

Here is how the four core subsystems work in real v1.0.1 code, the real-site browser bugs that forced our v1.0.1 fixes (Tailwind v4 lab()/oklch() computed paints, invisible animation layers, calc(infinity * 1px) pill radii, and Windows DPR 1.25 overlay drift), and where SpecPeek honestly stops.

1. Zero <all_urls> & Closed Shadow DOM Mounted on <html>

SpecPeek's built manifest.json (extension/dist/manifest.json, version: "1.0.1", minimum_chrome_version: "120") has no content_scripts array at all:

extension/dist/manifest.json JSON
{
  "manifest_version": 3,
  "version": "1.0.1",
  "minimum_chrome_version": "120",
  "incognito": "not_allowed",
  "background": { "service_worker": "background.js", "type": "module" },
  "permissions": ["activeTab", "scripting", "storage", "downloads"],
  "host_permissions": ["https://specpeek-api.packdemo.com/*"],
  "content_security_policy": {
    "extension_pages": "script-src 'self'; object-src 'none'; base-uri 'none'; connect-src https://specpeek-api.packdemo.com;"  }
}

The manifest declares four permissions and one host_permissions entry for optional paid licensing. Four architectural guardrails sit behind those permissions:

  1. On-demand isolated injection only: SpecPeek injects into supported webpages only after you click the toolbar icon or press Alt+Shift+P. On click, src/background.ts serializes per-tab toggles in a Map<number, Promise<void>> (preventing double-click races) and injects content.js into the ISOLATED world via chrome.scripting.executeScript({ target: { tabId }, world: 'ISOLATED', files: ['content.js'] }). Calling it again invokes globalThis.__specPeekClose(), which aborts a single AbortController, cancels any queued requestAnimationFrame, zeroes overlay canvas buffers, and detaches the host node.
  2. Restricted-origin handling without noisy errors: Because Chrome blocks scripting on chrome://, about:, and web store domains, background.ts detects restricted URLs and flips the action badge to an amber #b45309 ! with an explanatory tooltip rather than failing silently.
  3. Storage isolation & private key entry: At service-worker boot, background.ts calls chrome.storage.local.setAccessLevel({ accessLevel: 'TRUSTED_CONTEXTS' }). Content scripts injected into arbitrary websites can never read license state directly, and the in-page drawer never renders a license-key <input> on a third-party DOM. Activation happens exclusively on SpecPeek's own extension tab (license.html), enforced in background.ts:
    extension/src/background.ts TypeScript
    case 'license.activate':
      if (sender.url !== chrome.runtime.getURL('license.html')) {
        throw new Error('Open the private SpecPeek license page first.');
      }
    Everyday use with a license that has never been linked makes no extension network requests. Paid activation, revalidation and deactivation contact https://specpeek-api.packdemo.com/license/{activate|validate|deactivate} with { licenseKey, instanceId }, credentials: 'omit' and redirect: 'error'. Revalidation uses a 24h cache and 72h offline grace window (src/shared/license.ts).
  4. Closed Shadow DOM mounted on document.documentElement (<html>), not <body>: Mounting an inspector inside <body> breaks on React/Next.js apps that hydrate or replace <body> children, or inherit body flex/grid layouts and CSS transforms. In src/content/mount.ts, SpecPeek attaches directly to <html> with display: contents !important, a closed shadow root, constructable CSSStyleSheet.replaceSync(), and a MutationObserver that tears down cleanly if a hostile script removes the host:
extension/src/content/mount.ts TypeScript
const HOST_RULES = {
  all: 'initial',
  display: 'contents',
  direction: 'ltr',
  'unicode-bidi': 'isolate',
};

const host = doc.createElement('div');
host.setAttribute('data-specpeek-root', '');
for (const [key, value] of Object.entries(HOST_RULES)) {
  host.style.setProperty(key, value, 'important');
}
const root = host.attachShadow({ mode: 'closed' });
if (typeof win.CSSStyleSheet.prototype.replaceSync === 'function') {
  const styles = new win.CSSStyleSheet();
  styles.replaceSync(PANEL_CSS);
  root.adoptedStyleSheets = [styles];
}
doc.documentElement.append(host);

Key activation, keyboard and file-input handlers check event.isTrusted. Drag start checks it too; subsequent drag updates do not repeat that check.

2. Tailwind v4 Color Conversion and Layout Denoising (Local, No LLM)

Many "web-to-Tailwind" tools serialize a DOM subtree and ship it to a cloud LLM. That adds 2–8 seconds of latency, costs monthly token subscriptions, hallucinates non-existent utilities, and leaks whatever internal staging UI you are inspecting to a third-party server.

The SpecPeek extractor (style-data.ts, style-values.ts, code-exporter.ts, tailwind.ts, contrast.ts) performs deterministic local conversion with no LLM. Blind-testing v1.0.0 on live Tailwind v4 sites surfaced these Chromium quirks that we addressed in v1.0.1:

A. Restoring CSS Color 4 lab(), lch(), oklab(), oklch(), and display-p3

Modern Chromium no longer converts everything in getComputedStyle() to rgb(...). On Tailwind v4 sites, computed text and background values frequently arrive as D50 CIE lab(...) (for example, lab(1.90334 0.278696 -5.48866) for Tailwind v4's gray-950 #030712) or oklch(0.62796 0.25768 29.234 / .5) with percentage channels or none missing components. Naive hex/RGB regex parsers silently drop those colors—breaking both contrast badges and Tailwind class output.

In src/shared/contrast.ts, parseColor() handles hex, rgb(), hsl() and selected CSS Color 4 formats, including color(srgb ...), color(srgb-linear ...) and color(display-p3 ...). CIE lab()/lch() use D50-to-D65 Bradford adaptation; oklab()/oklch() use a separate LMS conversion. Here is the CIE Lab path:

extension/src/shared/contrast.ts TypeScript
function fromLab(l: number, a: number, b: number, alpha: number): Color {
  const fy = (l + 16) / 116;
  const inverse = (t: number) => (t > 6 / 29 ? t ** 3 : (116 * t - 16) / (24389 / 27));
  // CSS Lab uses D50. Adapt to D65 (Bradford), then convert to linear sRGB.
  const xd = 0.9642956764 * inverse(fy + a / 500),
    yd = inverse(fy),
    zd = 0.8251046025 * inverse(fy - b / 200);
  const x = 0.9554734215 * xd - 0.0230984549 * yd + 0.0632592432 * zd;
  const y = -0.0283697093 * xd + 1.0099953981 * yd + 0.0210414412 * zd;
  const z = 0.0123140149 * xd - 0.0205076493 * yd + 1.3303659262 * zd;
  return fromLinear(
    3.2409699419 * x - 1.5373831776 * y - 0.4986107603 * z,
    -0.9692436363 * x + 1.8759675015 * y + 0.0415550574 * z,
    0.0556300797 * x - 0.2039769589 * y + 1.0569715142 * z,
    alpha,
  );
}

After clipping and quantization to sRGB hex, lab(1.90334 0.278696 -5.48866) becomes #030712 (20.13:1 on #fff), and oklch(0.62796 0.25768 29.234 / .5) becomes #FF000080.

Just as important is what src/content/tailwind.ts deliberately does not guess:

extension/src/content/tailwind.ts TypeScript
// Legacy palette names aren't byte-identical across Tailwind v3 and v4.
const modern = /^(?:lab|lch|oklab|oklch|color)\(/i.test(value);
const named = Object.hasOwn(palette, hex) && (!modern || hex === '#000000' || hex === '#FFFFFF');
return `${prefix}-${named ? palette[hex] : `[${hex}]`}`;

The Tailwind v4 OKLCH ramp differs from the v3 sRGB palette. To avoid assigning the wrong v3 name, SpecPeek emits quantized, clipped sRGB hex in arbitrary classes (text-[#030712], bg-[#FF000080]), retaining black and white for #000000 and #FFFFFF. The standalone web converter can preserve supported original values such as oklch().

Observed Chromium Computed Value Normalized Output in v1.0.1 Why Naive Parsers Break
lab(1.90334 0.278696 -5.48866) #030712 · text-[#030712] (20.13:1 on #fff) D50 CIE Lab drops out of hex/RGB regexes; v4 ramp isn't byte-identical to v3 sRGB names.
oklch(0.62796 0.25768 29.234 / .5) #FF000080 · bg-[#FF000080] Modern slash-alpha & OKLCH coordinates fail legacy color parsers.
calc(infinity * 1px) / 3.35544e+07px 9999px → rounded-full Blink serializes Tailwind v4's infinity pill radius into scientific-notation pixels.
border: 0px solid #ebebeb 'none' (stripped) Tailwind reset leaves zero-width borders on almost every element.

B. Linear layout & computed-style denoising

Raw getComputedStyle() dumps 300+ properties full of browser defaults, inherited typography, zero-alpha shadow layers, and frozen pixel widths. SpecPeek strips that noise in a linear pipeline:

  1. Live per-tag UA baseline inside the closed Shadow DOM (style-data.ts): When mounted, mount.ts creates an inert, aria-hidden="true" baseline-host inside the closed shadow root. createCapture(baseline) instantiates one clean probe node per tag (<button>, <h1>, <input>, etc.), reads its untouched UA styles across 61 curated properties (Layout, Spacing, Typography, Visual, Effects), removes the probe, and caches the baseline in a Map. Only properties that actually differ from UA defaults survive diff() in code-exporter.ts.
  2. CSS Typed OM for auto and % (style-data.ts): getComputedStyle(el).width freezes used pixels (347.25px) even when the author wrote width: 100% or auto. For layout lengths (width, height, min/max-*, top/right/bottom/left), readStyles() checks el.computedStyleMap?.()?.get(key)?.toString() first so 100% becomes w-full and auto stays w-auto.
  3. Inherited typography stripping + Preflight guards (style-data.ts): Inherited typography properties (font-family, font-size, line-height, letter-spacing, text-align, etc.) are pruned when identical to the computed parent style—except on elements Tailwind Preflight resets (h1–h6, button, input, select, textarea), and whenever font-size changes, line-height is explicitly forwarded so Tailwind's text-sm default leading never silently overrides the measured value.
  4. Invisible border, transparent shadow, and Blink infinity-radius normalization (style-values.ts):
    • border: 0px solid #ebebeb (emitted on nearly every Tailwind reset element) normalizes to 'none' and drops out.
    • Parenthesis-aware shadowLayers() strips zero-alpha layers like rgba(0, 0, 0, 0) 0px 0px 0px 0px and 0 0 2px oklch(0.4 0.2 30 / 0) while preserving visible layers.
    • Tailwind v4's rounded-full (calc(infinity * 1px)) serializes in Blink as 3.35544e+07px; normalizeStyleValue() detects both >= 9999px and calc(infinity * 1px) and collapses them to 9999px → rounded-full.
  5. Skipping opacity: 0 animation decoys (hud-inspector.ts): Marketing sites routinely stack invisible opacity: 0 headline layers on top of visible text for scroll animations. hitAtPointer() checks item.checkVisibility({ checkOpacity: true }) and falls back through elementsFromPoint(x, y) (and nested open shadowRoots) to land on the actual painted element.

Finally, safeCssValue() rejects values over 1,200 chars, control characters, <>{};\, and resource-bearing CSS functions (url(), image-set(), paint(), attr(), var()), so copying styles off an untrusted page can never inject tracking beacons or break JSX attribute quoting.

3. Extracting Current-Page DESIGN.md + W3C Design Tokens (Without Polluting Your AI Agent)

Prompting Cursor, Claude Code, v0, or Lovable with "build a clean modern SaaS dashboard" produces generic purple-gradient boilerplate. Handing the agent a concise, machine-grounded DESIGN.md—following the agent-readable Markdown design-brief convention popularized by google-labs-code/design.md—dramatically reduces cross-session UI drift.

The catch is that dumping every computed color on a page creates a 200-line spec stuffed with 14 one-off grays and synthetic Next.js fallback fonts (__Inter_Fallback_...) that confuse coding agents just as badly as no spec at all.

Non-blocking page scan & signal filtering (page-scanner.ts)

scanPage() traverses document.documentElement and open shadow roots iteratively, yielding back to the main thread every 200 nodes (visited % 200 === 0) via a cancellable AbortSignal timer so large SPAs stay responsive:

  • Synthetic fallback font filtering: isDesignFont() strips Next.js/framework synthetic fallback names (/(?:\s+fallback$|^__.*_fallback(?:_|$))/i) while combining loaded document.fonts faces with active text stacks across 9 type roles (h1–h6, body, button, code).
  • CTA-aware accent ranking: Instead of treating every colored link or full-card <a> as the brand accent, page-scanner.ts scores interactive controls (ACTIVE_CONTROLS) by distinguishing solid padded buttons (buttonLike: opaque fill alpha >= 0.85, no backgroundImage, text <= 48 chars with inline padding) and weighting repeat usage + chroma (count + (vivid ? 2 : 0)) so a single demo badge doesn't outrank the page's primary CTA.
  • Frequency gating in token-exporter.ts: Secondary swatches, radii, shadows, component patterns, and spacing steps (<= 128px) require repeated usage (count > 1) before entering DESIGN.md, keeping the brief dense and high-signal.

Four deterministic handoff artifacts + style-inlined SVGs (Pro and Agency)

Free users get a top-five token preview. Pro Solo and Agency unlock full token exports: exportTokens() emits four synchronized local files from one PageScan:

Artifact Format & Structure Key Engineering Details
DESIGN.md Structured Markdown brief # DESIGN.md, ## Palette roles, ## Type scale, ## Radii, ## Shadows, ## Spacing rhythm, ## Component patterns, ## Implementation notes, with explicit scope header: Source: current page sample (N visible elements). Not a full-site crawl.
design-tokens.json W3C Design Tokens (DTCG) JSON Uses $type (color, dimension, shadow, typography) and $value with structured colorSpace: "srgb" normalized [0..1] components, alpha, hex, and typed { value, unit } dimensions.
tailwind-theme.css Tailwind v4 @theme + v3 snippet Ready-to-import @theme block (--color-spec-*, --font-spec-*, --text-spec-*, --radius-spec-*, --spacing-spec-*, --shadow-spec-*) plus a commented Tailwind v3 theme.extend ESM snippet.
variables.css Plain CSS custom properties Standard :root custom properties prefixed with --sp-*.

Need icons too? serializeSvg() (svg-cleaner.ts) resolves currentColor and computed presentation attributes onto an allowlisted XML tree, hoists sibling <symbol>/gradient #id references into a self-contained <defs> block (fixing the classic "all-black exported SVG" bug), and enforces strict 20,000-node and 150-depth safety caps (skippedOversizedSvgs). All four token files plus cleaned SVGs pack locally into specpeek-brand-kit.zip using a 58-line zero-dependency Store-mode ZIP32 builder (shared/zip-pack.ts).

4. Local Pixel-Overlay QA and CSS-Pixel Calibration

Overlaying a designer's PNG/WebP mockup on top of your staging build is the fastest way to catch 1–2px spacing or baseline regressions—yet most Chrome overlay extensions inject ads or lock basic layers behind aggressive paywalls.

SpecPeek renders overlay canvases inside its closed Shadow DOM. New layers start in Normal at 55% opacity; you can switch to Difference (mix-blend-mode: difference). At 100% overlay opacity, matching opaque pixels blend to pure black (#000000). Overlays use requestAnimationFrame-coalesced scroll tracking, default click-through locking, 1px / 10px (Shift + Arrow) nudges, and per-origin IndexedDB persistence (specpeek-overlays).

Pre-decode decompression-bomb guards (pixel-overlay.ts)

Before calling createImageBitmap(), SpecPeek never trusts file extensions:

  1. Enforces a 16 MB file cap (MAX_MOCKUP_BYTES).
  2. Sniffs magic bytes for PNG (89 50 4E 47 0D 0A 1A 0A), JPEG (FF D8 FF), or WebP (RIFF...WEBP).
  3. Parses binary headers directly (PNG IHDR, JPEG SOF, WebP VP8X/VP8L/VP8 ) to reject any image exceeding 16,384 px per side or 40,000,000 pixels (40 MP) before a single RGBA buffer is allocated, then closes ImageBitmap immediately in finally and restores multi-layer stacks sequentially.

Why 0.5× / 1× / 2× broke on Windows DPR 1.25 — and the targetWidth fix

In v1.0.0, overlays only offered discrete 0.5×, 1×, and 2× scales. That works cleanly on 1× monitors or 2× Retina Macs—and immediately drifts on Windows laptops running 125% (devicePixelRatio = 1.25) or 150% (1.5) display scaling, or whenever a designer exports a 1440px Figma artboard that you QA inside a 1280px or 1519px CSS-pixel viewport.

On a 1920×1080 Windows display at 125% scaling, the physical screenshot is 1920px wide while the CSS viewport is 1536px (or ~1519px minus scrollbar). Aligning physical pixels to CSS pixels requires a 0.8× scale (1 / 1.25)—something 0.5× / 1× / 2× presets can never hit.

In v1.0.1, we added continuous CSS-pixel targetWidth calibration (1..100,000 CSS px) plus a one-click Fit viewport action in pixel-overlay.ts and panel-overlay.ts:

extension/src/content/pixel-overlay.ts TypeScript
const paint = (layer: OverlayLayer, canvas: HTMLCanvasElement) => {
  canvas.hidden = !layer.visible;
  const scale = layer.targetWidth == null
    ? layer.scale
    : layer.targetWidth / canvas.width;
  canvas.style.transform =
    `translate(${layer.x - win.scrollX}px, ${layer.y - win.scrollY}px) ` +
    `scale(${scale})`;
  canvas.style.opacity = String(layer.opacity);
  canvas.style.mixBlendMode = layer.difference ? 'difference' : 'normal';
  canvas.style.filter = layer.invert ? 'invert(1)' : 'none';
  canvas.style.pointerEvents = layer.locked ? 'none' : 'auto';
};

// Set the target width to the current layout viewport in CSS pixels:
fitViewport(id: string) {
  return update(id, {
    targetWidth: document.documentElement.clientWidth || win.innerWidth,
  });
}

Fit viewport sets the target width to the current layout viewport in CSS pixels, using document.documentElement.clientWidth (excluding the scrollbar) or window.innerWidth as a fallback. This sets width only: adjust X/Y to line up the mockup with the page. Agency exports use schema version: 2 when a layer has targetWidth and remain compatible with version: 1 presets (shared/overlay-model.ts).

5. Honest Limitations

No browser extension should pretend to replace every tool in your stack. Here is what SpecPeek deliberately does not do:

  1. Current-page sampling only—not a full-site crawler: DESIGN.md and token exports only reflect the rendered DOM of the currently open page. They cannot discover unvisited routes, define responsive breakpoint matrices, or replace Figma as a multi-team component source of truth.
  2. Same-origin and CORS boundaries are strictly respected: SpecPeek cannot inspect inside cross-origin <iframe> documents (the HUD explicitly reports Embedded frame · separate document), cannot bypass browser restrictions on cross-origin external stylesheets, and refuses to covertly refetch CORS-tainted images (canvas.toBlob fails cleanly with an explanation).
  3. No :hover / :focus pseudo-state or @media inference, and intentionally minimal JSX: Deterministic getComputedStyle reflects the element's live state right now—it will not invent md:grid-cols-3 or hover:bg-blue-700. JSX export caps at the selected node plus optional immediate children and deliberately replaces DOM text with literal "Text" so staging copy or customer data never leaks into your clipboard. Chrome DevTools remains the right tool for cascade specificity debugging and live rule editing.
  4. Extension Tailwind scale and sRGB gamut: The extension emits arbitrary shadow-[...] values and classic radius tokens (4px → rounded, 2px → rounded-sm); infinity radii normalize to 9999px / rounded-full. It clips and quantizes modern colors to sRGB hex. The standalone CSS-to-Tailwind converter offers v3/v4 switching and a Preserve raw oklch()/lab() option for supported values.
  5. Honest contrast boundaries: When an ancestor uses opacity !== 1, filter, mix-blend-mode, background-image, or non-blur backdrop-filter, SpecPeek refuses to guess a WCAG ratio and explicitly reports Contrast unknown.
  6. Browser support: Chrome Web Store offers v1.0.1 for Chromium 120+; the Chromium manifest disables incognito injection. The v1.0.1 build for Firefox 140+ is ready and awaiting public listing. Safari has no version.

Try It Locally (Zero Install or via Chrome Web Store)

The three free standalone tools below enforce connect-src 'none' and no-referrer in HTTP headers and page metadata. After load, conversion and export send no user data or analytics requests. The homepage loads only same-origin page assets and config.json, with no analytics script; comparison pages and this article use a cookieless first-party counter.

Install SpecPeek from the Chrome Web Store. Free includes unlimited hover inspection, distance rulers and contrast checks, three element code exports per day (reset at midnight UTC), a top-five token preview and one overlay layer per site. Pro Solo and Agency add full DESIGN.md, Tailwind v4 @theme, W3C JSON and Brand Kit ZIP exports, plus unlimited overlay layers.

Air-gapped browser tools · CSP connect-src 'none'

Try the standalone tools in your browser

No signup or API keys. After the page loads, conversion and export send no user data or analytics requests.

Free · Offline

DESIGN.md & Tailwind v4 @theme Builder

Compose palette roles and typography scales, then export DESIGN.md, Tailwind v4 @theme, or W3C Design Tokens JSON locally.

Open DESIGN.md Builder →
Free · v3 / v4

CSS to Tailwind Converter

Paste computed CSS (lab(), lch(), oklch(), display-p3, calc(infinity * 1px), logical padding) and switch cleanly between Tailwind v3 and v4.

Open CSS to Tailwind →
Free · WCAG + APCA

WCAG 2.2 & APCA Contrast Checker

Dual WCAG 2.2 and APCA (Lc) audit across HEX, RGB, HSL, lab()/lch(), oklch(), and display-p3 with one-click OKLCH auto-fix.

Open Contrast Checker →
Want the Free hover HUD and rulers, or full DESIGN.md exports with Pro? Install SpecPeek Free Forever on Chrome, Edge, Brave, or Arc. Pro Solo is $39 once (3 devices, 14-day refund) — never a subscription.
Add SpecPeek to Chrome — Free See Pro · $39 Once