{"id":49940227,"url":"https://github.com/andrecrjr/mockzilla-chrome-extension","last_synced_at":"2026-05-17T10:36:49.820Z","repository":{"id":321786899,"uuid":"1086758263","full_name":"andrecrjr/mockzilla-chrome-extension","owner":"andrecrjr","description":"Mockzilla Browser Extension is for Fast Mock Responses!","archived":false,"fork":false,"pushed_at":"2026-04-16T03:16:18.000Z","size":3946,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-16T04:24:59.577Z","etag":null,"topics":["chrome-extension","developer-tools","development","devtools-extension","http-server","mock","mocking","mockserverresponse","rest-api"],"latest_commit_sha":null,"homepage":"https://mockzilla.dev","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andrecrjr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2025-10-30T21:32:50.000Z","updated_at":"2026-02-26T23:48:32.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/andrecrjr/mockzilla-chrome-extension","commit_stats":null,"previous_names":["andrecrjr/fastmock","andrecrjr/mockzilla-chrome-extension"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/andrecrjr/mockzilla-chrome-extension","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrecrjr%2Fmockzilla-chrome-extension","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrecrjr%2Fmockzilla-chrome-extension/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrecrjr%2Fmockzilla-chrome-extension/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrecrjr%2Fmockzilla-chrome-extension/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andrecrjr","download_url":"https://codeload.github.com/andrecrjr/mockzilla-chrome-extension/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrecrjr%2Fmockzilla-chrome-extension/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33135105,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-17T09:28:26.183Z","status":"ssl_error","status_checked_at":"2026-05-17T09:27:52.702Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chrome-extension","developer-tools","development","devtools-extension","http-server","mock","mocking","mockserverresponse","rest-api"],"created_at":"2026-05-17T10:36:48.012Z","updated_at":"2026-05-17T10:36:49.810Z","avatar_url":"https://github.com/andrecrjr.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mockzilla\n\nMockzilla is a Chrome extension that intercepts page-level `fetch` and `XMLHttpRequest` calls and returns mocked responses based on rules you define. It’s ideal for prototyping, isolating frontend work from unstable APIs, and reproducing edge cases without changing backend services.\n\n## Overview\n- Intercepts requests initiated from the page context (not network-wide).\n- Matches requests via `substring` or `exact` URL patterns.\n- Returns `text` or `json` bodies with `200 OK` status.\n- Tracks per-tab rule hits and last matched URL to help verify mocks.\n- Resilient to CSP: falls back to programmatic injection in the page’s main world.\n\n## Features\n- Multiple rules with independent pattern, match type, and body type.\n- Live editing in the popup: changes persist immediately.\n- Per-tab hit counters with last matched URL for each rule.\n- Syncs rule metadata across devices via `chrome.storage.sync`.\n- Stores large mock bodies locally via `chrome.storage.local` (avoids sync quotas).\n\n## Installation\n- Enable Developer Mode in Chrome (`chrome://extensions/`).\n- Click `Load unpacked` and select the project folder: `mockzilla`.\n- The extension icon will appear; open the popup to start adding rules.\n\n## Usage\n- Open the extension popup and click `Add Rule`.\n- Set `Match Type`:\n  - `Substring`: matches if the URL contains your pattern (absolute or relative).\n  - `Exact`: matches only when the normalized absolute URL equals your pattern.\n- Enter `URL pattern` (absolute or relative). Quotes around the pattern are stripped automatically.\n- Choose `Body Type`:\n  - `Text`: raw string returned with `Content-Type: text/plain`.\n  - `JSON`: parsed with `JSON.parse`; if invalid, returned as string. Response header is `application/json`.\n- Fill `Replacement body` and navigate or trigger requests on the page. Hits appear under each rule with the last matched URL.\n- Use `Clear Hits` to reset counters for the current tab.\n- Use `Delete` to remove a rule.\n\n## Rule Matching\n- Patterns are normalized and compared to request URLs as absolute URLs when possible.\n- `Exact` compares absolute forms; `Substring` checks both raw and absolute forms.\n- Quotes/backticks around patterns are removed (e.g., `\"/api/users\"`).\n- Relative patterns (e.g., `/api/users`) are valid; they’re resolved against `location.href`.\n\n## How It Works\n- `content-script.js` injects `injected.js` at `document_start` to override page `fetch` and `XMLHttpRequest`.\n- Rules are loaded from storage and sent into the page via `window.postMessage`.\n- `injected.js` applies the patches, finds matching rules, builds responses, and reports hits.\n- `background.js` tracks per-tab hit counts in `chrome.storage.session` and serves them to the popup.\n- If CSP blocks tag injection, the background script programmatically injects `injected.js` into the page’s `MAIN` world via `chrome.scripting`.\n\n## Permissions\n- `scripting`, `storage`, `activeTab`, `tabs`\n- `host_permissions`: `\u003call_urls\u003e`\n- Manifest version: `3` (`service_worker` background).\n\n## Data \u0026 Privacy\n- Rule metadata (`matchType`, `pattern`, `bodyType`) is stored in `chrome.storage.sync` for portability.\n- Rule bodies are stored in `chrome.storage.local` to avoid per-item sync quotas.\n- Hit counters live in `chrome.storage.session` and reset with the browser session.\n- No data leaves your browser; all operations are local.\n\n## Development\n- Files:\n  - `manifest.json`: extension config and permissions.\n  - `popup.html` / `popup.js`: UI for managing rules and viewing hits.\n  - `content-script.js`: injects page script and syncs rules to page context.\n  - `injected.js`: overrides `fetch`/`XHR`, applies matching and returns responses.\n  - `background.js`: tracks hits, handles injection fallback, answers popup requests.\n- Typical workflow:\n  - Edit rules via the popup and test on any page.\n  - Use DevTools console to observe logs from `injected.js` and content script.\n  - Reload the extension from `chrome://extensions/` when you change source files.\n\n## Design System (Tailwind CSS)\n- Color scheme:\n  - Primary: Tailwind `blue` (actions, focus rings)\n  - Neutral: Tailwind `gray`/`slate` (surfaces, borders, text)\n  - Success: Tailwind `green` (positive feedback)\n  - Danger: Tailwind `red` (destructive actions, validation errors)\n- Typography:\n  - Base `text-sm` for headers, `text-xs` for inputs and meta text\n  - Clear hierarchy via `font-semibold` in headers and action buttons\n- Spacing:\n  - Consistent `px-3 py-2` for headers, `px-3 py-1` for controls\n  - `space-y-2` for stacked lists; `gap-2` for inline control groups\n- Components (defined via `@layer components` in `popup.html`):\n  - `btn`, `btn-primary`, `btn-neutral`, `btn-danger`\n  - `input`, `select`, `textarea`, `card`, `label`\n  - All interactive elements include `focus-visible` rings for accessibility\n- States \u0026 feedback:\n  - The status area (`#statusMessage`) shows transient messages for saves, errors, and toggles with semantic colors.\n\n## Accessibility\n- Keyboard navigation:\n  - Rule headers are focusable; `Enter`/`Space` toggles the accordion.\n  - Arrow keys navigate between rule headers; `Home`/`End` jumps to first/last.\n- ARIA:\n  - Toggle uses `role=\"switch\"` with `aria-checked` state.\n  - Panels use `role=\"region\"` and are labelled by their headers.\n  - Validation sets `aria-invalid` and displays an alert region when JSON is invalid.\n- Contrast:\n  - Buttons and focus rings use accessible color pairs (e.g. blue-600 on white).\n\n## Responsive Layouts\n- The popup adapts from `min-w-[360px]` (compact) up to `md:min-w-[600px]`.\n- Content scrolls inside the rules list while the header remains accessible.\n\n## Notes on Preview Functionality\n- There is no preview pane in the popup UI. The redesign removes any prior preview-related UI, while preserving all rule management features.\n\n## Troubleshooting\n- Mocks not applying:\n  - Confirm the pattern matches the request URL; try `substring` first.\n  - Ensure the page initiates the request via `fetch`/`XHR` (service worker or extension requests aren’t intercepted).\n  - Check console logs: look for \"Mockzilla: injected.js loaded\" and any warnings.\n- JSON body not returning as expected:\n  - Validate the JSON; invalid JSON is returned as a string.\n- No hits recorded:\n  - Verify the tab is active; counters are per-tab.\n  - Click `Clear Hits` to reset and try again.\n\n## Notes\n- Responses always return `200 OK` with the designated `Content-Type`.\n- This extension patches page context only. Network-level interception (`chrome.webRequest`) is not used.\n- Patterns may include quotes; they’re stripped for matching.\n\n## Credits\n- **Made by AC-JR**: [Sponsor / Website](https://github.com/andrecrjr) (Link to be updated if specific site provided)\n- **Powered by MSW**: Special thanks to [Mock Service Worker](https://mswjs.io/) for their incredible interception library.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrecrjr%2Fmockzilla-chrome-extension","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandrecrjr%2Fmockzilla-chrome-extension","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrecrjr%2Fmockzilla-chrome-extension/lists"}