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:
{
"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:
-
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.tsserializes per-tab toggles in aMap<number, Promise<void>>(preventing double-click races) and injectscontent.jsinto theISOLATEDworld viachrome.scripting.executeScript({ target: { tabId }, world: 'ISOLATED', files: ['content.js'] }). Calling it again invokesglobalThis.__specPeekClose(), which aborts a singleAbortController, cancels any queuedrequestAnimationFrame, zeroes overlay canvas buffers, and detaches the host node. -
Restricted-origin handling without noisy errors: Because Chrome blocks scripting on
chrome://,about:, and web store domains,background.tsdetects restricted URLs and flips the action badge to an amber#b45309!with an explanatory tooltip rather than failing silently. -
Storage isolation & private key entry: At service-worker boot,
background.tscallschrome.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 inbackground.ts:Everyday use with a license that has never been linked makes no extension network requests. Paid activation, revalidation and deactivation contactextension/src/background.ts TypeScriptcase 'license.activate': if (sender.url !== chrome.runtime.getURL('license.html')) { throw new Error('Open the private SpecPeek license page first.'); }https://specpeek-api.packdemo.com/license/{activate|validate|deactivate}with{ licenseKey, instanceId },credentials: 'omit'andredirect: 'error'. Revalidation uses a24hcache and72hoffline grace window (src/shared/license.ts). -
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 inheritbodyflex/grid layouts and CSS transforms. Insrc/content/mount.ts, SpecPeek attaches directly to<html>withdisplay: contents !important, a closed shadow root, constructableCSSStyleSheet.replaceSync(), and aMutationObserverthat tears down cleanly if a hostile script removes the host:
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:
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:
// 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:
-
Live per-tag UA baseline inside the closed Shadow DOM (
style-data.ts): When mounted,mount.tscreates aninert,aria-hidden="true"baseline-hostinside 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 aMap. Only properties that actually differ from UA defaults survivediff()incode-exporter.ts. -
CSS Typed OM for
autoand%(style-data.ts):getComputedStyle(el).widthfreezes used pixels (347.25px) even when the author wrotewidth: 100%orauto. For layout lengths (width,height,min/max-*,top/right/bottom/left),readStyles()checksel.computedStyleMap?.()?.get(key)?.toString()first so100%becomesw-fullandautostaysw-auto. -
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 wheneverfont-sizechanges,line-heightis explicitly forwarded so Tailwind'stext-smdefault leading never silently overrides the measured value. -
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 likergba(0, 0, 0, 0) 0px 0px 0px 0pxand0 0 2px oklch(0.4 0.2 30 / 0)while preserving visible layers. - Tailwind v4's
rounded-full(calc(infinity * 1px)) serializes in Blink as3.35544e+07px;normalizeStyleValue()detects both>= 9999pxandcalc(infinity * 1px)and collapses them to9999px→rounded-full.
-
Skipping
opacity: 0animation decoys (hud-inspector.ts): Marketing sites routinely stack invisibleopacity: 0headline layers on top of visible text for scroll animations.hitAtPointer()checksitem.checkVisibility({ checkOpacity: true })and falls back throughelementsFromPoint(x, y)(and nested openshadowRoots) 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 loadeddocument.fontsfaces 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.tsscores interactive controls (ACTIVE_CONTROLS) by distinguishing solid padded buttons (buttonLike: opaque fillalpha >= 0.85, nobackgroundImage, text<= 48chars 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 enteringDESIGN.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:
- Enforces a
16 MBfile cap (MAX_MOCKUP_BYTES). - Sniffs magic bytes for PNG (
89 50 4E 47 0D 0A 1A 0A), JPEG (FF D8 FF), or WebP (RIFF...WEBP). - Parses binary headers directly (
PNG IHDR,JPEG SOF,WebP VP8X/VP8L/VP8) to reject any image exceeding16,384 pxper side or40,000,000pixels (40 MP) before a single RGBA buffer is allocated, then closesImageBitmapimmediately infinallyand 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:
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:
-
Current-page sampling only—not a full-site crawler:
DESIGN.mdand 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. -
Same-origin and CORS boundaries are strictly respected: SpecPeek cannot inspect inside cross-origin
<iframe>documents (the HUD explicitly reportsEmbedded frame · separate document), cannot bypass browser restrictions on cross-origin external stylesheets, and refuses to covertly refetch CORS-tainted images (canvas.toBlobfails cleanly with an explanation). -
No
:hover/:focuspseudo-state or@mediainference, and intentionally minimal JSX: DeterministicgetComputedStylereflects the element's live state right now—it will not inventmd:grid-cols-3orhover: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. -
Extension Tailwind scale and sRGB gamut: The extension emits arbitrary
shadow-[...]values and classic radius tokens (4px→rounded,2px→rounded-sm); infinity radii normalize to9999px/rounded-full. It clips and quantizes modern colors to sRGB hex. The standalone CSS-to-Tailwind converter offers v3/v4 switching and aPreserve raw oklch()/lab()option for supported values. -
Honest contrast boundaries: When an ancestor uses
opacity !== 1,filter,mix-blend-mode,background-image, or non-blurbackdrop-filter, SpecPeek refuses to guess a WCAG ratio and explicitly reportsContrast unknown. -
Browser support: Chrome Web Store offers
v1.0.1for Chromium 120+; the Chromium manifest disables incognito injection. Thev1.0.1build 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.