All MicroEvals
Build a Manifest V3 Chrome extension called "Claude Gate", a...
Create MicroEval

Build a Manifest V3 Chrome extension called "Claude Gate", a...

Prompt

Build a Manifest V3 Chrome extension called "Claude Gate", a matching Python key generator (`keygen.py`), `GATEKEEPER_PROMPT.md`, and `README.md`. Test in a real Chromium instance if your environment supports it; report honestly which tests ran and never claim untested code works. ## Purpose A self-control tool that blocks almost every website. The user unlocks a site temporarily by redeeming a signed key issued by Claude in chat. Document honestly in `README.md` that this is friction, not security (the user can disable the extension or inspect local storage). ## Core Blocking & Always Allowed 1. **Catch-all block (Priority 1):** Use `declarativeNetRequest` dynamic rules (`resourceTypes: ["main_frame"]` only) with `regexFilter: "^https?://([^/:?#]+)(.*)"` redirecting to `blocked.html?d=\1&u=\0`. 2. **Baseline Always Allowed (Priority 2, cannot disable):** `claude.ai`, `anthropic.com`, `consent.google.com`, Google Sign-In/OAuth on `accounts.google.com`, and Google Search only (`google.*` `/`, `/search`, `/webhp`). YouTube stays blocked. 3. **Customizable Always Allowed (Priority 2):** - **Instant toggles:** **Google Work Tools** (`mail/drive/docs/calendar/meet/keep/contacts/tasks.google.com`; keep YouTube blocked) and **Messenger (Chat Only)** (`facebook.com/messages`, login/checkpoint paths, and `messenger.com`; block Facebook feed/Reels/profiles). Add a `webNavigation.onHistoryStateUpdated` SPA listener so navigating away from `/messages` inside Facebook immediately redirects to `blocked.html`. - **Custom domains:** Normalized hostnames. Removing is instant. Adding is instant during first-run setup, then locked behind a **10-minute cooldown** via `chrome.alarms` (auto-completes even if dashboard is closed) with a live countdown and **Cancel** button (canceling counts as a Resisted Urge). Log custom additions in history and the 7-day report. 4. **Temporary unlocks (Priority 3):** Per-domain `requestDomains` allow rule (covers subdomains), expired via `chrome.alarms`, reconciled with `chrome.storage.local` on `onStartup`/`onInstalled`. On unlock, validate the preserved `http(s)` URL and redirect to the exact page originally requested. 5. **First run:** `blocked.html` lets the user set a 12+ char secret (settable once, stored in `chrome.storage.local`), toggle work packs, add initial custom Always Allowed sites, and click Finish Setup. ## Key Protocol (Exact Parity: Python & WebCrypto) - **Domain normalization:** Lowercase, strip leading `www.`, host only. - **Challenge:** 5-char nonce from `"abcdefghjkmnpqrstuvwxyz23456789"` + compact telemetry `meta` = `"a<attemptsToday>-r<remainingBudgetMin>-h<localHour2Digit>"` (e.g., `a6-r25-h01`). Store `{ nonce, meta, createdAt }` per domain; expires after **15 minutes** (failed keys must not consume it; validate against stored `meta`). Display as `<domain>~<nonce>~<meta>`. - **Signing:** `scope` is `full` or `focus`; `minutes` is `1–240`. `mac` = first 10 lowercase hex chars of `HMAC-SHA256(secret, "<domain>|<minutes>|<nonce>|<meta>|<scope>")`. `key` = `"<minutes>-<scope>-<mac>"`. - **Redemption:** Unlocks during 23:00–05:00 local time cost **2x** daily budget. Refuse if over remaining budget. On success, delete nonce, activate unlock, log intent/scope, and redirect to the original URL. - **`keygen.py`:** `python keygen.py SECRET REQUEST_CODE MINUTES [SCOPE]` (default `full`, optional `--verbose`). ## Behavioral Loop & Focus Mode - **Stated intent:** Short input on `blocked.html` + **Copy for Claude** (`[Claude Gate] <request_code> | Intent: <intent>`) + **Open Claude** button. - **Cooling-off gate:** At 6+ blocked attempts today or between 23:00–05:00, hide the request code behind a calm 30-second breathing timer. Track closed blocked tabs (and canceled 10-min cooldowns) as **Resisted Urges**. - **Focus Mode (`focus`):** Inject built-in CSS hiding distracting feeds/recs on YouTube (homepage/Shorts/sidebar), Reddit (feeds/sidebar), and X (trending/"For You"). - **Soft landing & refunds:** For 4+ min unlocks, show a T-2 min corner toast with a **Done Early (Re-lock)** button (also on dashboard) that re-locks immediately, redirects tabs to `blocked.html?done=1`, and refunds remaining whole minutes as **Minutes Reclaimed**. Natural expiry redirects all open tabs of that domain across all windows to `blocked.html?e=1` with a 1-click intent check-in ("Finished it" / "Got pulled in"). ## Visual Theme (Cozy Fox Shrine) Use zero external fonts, images, or CSS frameworks. Style `blocked.html`, the dashboard, and the T-2 min toast with a cohesive Japanese fox-shrine aesthetic: - **Daytime palette:** Warm washi-paper cream backgrounds (`#FDF7EC`, `#F6EDE0`), soft warm-charcoal ink (`#3A2B24`), fox-amber accents (`#E58E26`), muted torii-vermilion highlights (`#C84B31`), and calm matcha-sage (`#5F8D4E`) for Resisted Urges and Reclaimed Minutes. - **Auto late-night palette (23:00–05:00 local time):** Automatically switch `blocked.html` and the dashboard to a low-glare lantern-lit twilight theme (deep warm plum/indigo `#1F1A24` surfaces with soft amber `#F3A83B` lantern glow and warm parchment text) to protect eyes and gently cue bedtime. - **Inline SVG motif:** Include a clean, tasteful inline SVG fox-spirit/lantern emblem on `blocked.html` and the dashboard header, paired with refined system serif headings and clean sans-serif UI controls. ## Dashboard (Toolbar Icon) No external libs/CDNs, inline SVG charts, separate JS files (MV3 CSP). Show: - Today's stats: blocks, Resisted Urges, unlocks, granted vs. budget, reclaimed, real minutes used, intent follow-through %, budget streak. - Active unlocks with live countdowns, scope badge, intent, and Done Early button. - Always Allowed manager (Work Tools & Messenger toggles, custom list, add input, Pending 10:00 cooldown queue with Cancel). - 14-day SVG charts (attempts; granted vs. used), hour-of-day heat strip (23:00–05:00 highlighted), top sites, recent log. - Editable daily budget (default 120m; increases logged as an Honor Signal). Buttons: Copy 7-day report (includes new Always Allowed sites + Honor Signals), Export JSON, Reset History (keeps secret & Always Allowed). - **Usage heartbeat (1-min alarm):** Count 1 min if focused active tab is on an unlocked domain AND (`chrome.idle` is `"active"` OR `tab.audible` is `true`). Log >5-min gaps while running as an Honor Signal. Use local dates; cap log at 3,000 events. ## Personality & Gatekeeper Kit - **Helpful Fox Spirit copy (inspired by Senko-san):** Write all original lines in the voice of a warm, doting 800-year-old fox spirit caretaker dedicated to clearing away the user's stress ("dark aura") and helping them rest. Use a gentle, slightly old-fashioned grandmotherly cadence (*"Now, now..."*, *"Goodness me..."*, *"There, there..."*), occasional lighthearted remarks about living 800 years, playful bewilderment at noisy modern tech/screens, wholesome mentions of tea, rest, or twitching fox ears, and soft flustered fussing (never harsh, sarcastic, or cringey). Keep all lines in one config object covering: first visit, 3+ attempts (gentle check-in), 6+ attempts (worried fussing), late night 23:00–05:00 (insisting on sleep + noting 2x budget cost), 30s breathing countdown, wrong key (flustered *"Eeep!"* / gentle retry), expired challenge, budget exceeded, unlock success (`focus` vs `full`), 2-min toast, Done Early praise, cooldown canceled praise, and time's up check-in. - **`GATEKEEPER_PROMPT.md`:** Ready-to-paste Claude Project instructions in this same warm Senko-san-inspired caretaker voice explaining how to decode `meta`, kindly nudge back on vague intents ("just checking"), prefer `focus` keys for feed sites, protect the user's sleep late at night, run `keygen.py`, and host a cozy "Sunday Tea" review of the 7-day report (celebrating Resisted Urges and gently checking in on newly added Always Allowed sites and Honor Signals without scolding). ## Pitfalls & Automated Tests - Put `&u=\0` **last** in `regexSubstitution` and slice after `&u=` in JS to preserve full query/hash URLs; normalize `d` defensively. - Add `blocked.html` to `web_accessible_resources` (`matches: ["<all_urls>"]`) so link-click redirects don't fail with `ERR_BLOCKED_BY_CLIENT`. - Include `declarativeNetRequest`, `declarativeNetRequestWithHostAccess`, `webNavigation`, `scripting`, `alarms`, `idle`, `storage`, `tabs`, and `<all_urls>`. Never put slashes in `requestDomains`. Keep zero state in service-worker globals. Document in `README.md` that reloading keeps storage while removing erases the secret. - **Tests:** Unit/parity tests (`keygen.py` vs. WebCrypto for `full`/`focus`, normalization, 15m expiry, 2x night math, audible usage) + Playwright Chromium E2E covering: first-run setup, typed & link-click blocks, deep URL redirect after unlock, `www.` vs bare domain, wrong key, `focus` CSS injection, `full` unlock, key reuse refusal, 30s pause & Resisted Urges, Done Early refund, natural expiry `?e=1`, Google Search/OAuth allowed & YouTube blocked, Google Work Tools toggle, Messenger `/messages` allowed vs `/feed` + SPA nav blocked, 10-min custom cooldown (cancel & complete), budget refusal, and browser-restart persistence.

A system prompt was added to support web rendering

Response not available

Drag to resize

Response not available

Drag to resize
Drag to resize
Drag to resize
Drag to resize