mirror of
https://github.com/Dasemu/Phenocheck.git
synced 2026-11-26 15:26:17 +00:00
Add root CLAUDE.md, docs/architecture.md, LESSONS.md, .env.example, .claude/settings.json hooks (PostToolUse JS syntax check, Stop hook validating manifest.json + node --check on all JS), and GitHub Actions workflows (ci.yml, version.yml) for this plain-JS Chrome extension with no existing build/lint/test tooling. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
30 lines
1.5 KiB
Markdown
30 lines
1.5 KiB
Markdown
# Architecture
|
|
|
|
Phenocheck is a Manifest V3 Chrome extension with no build step.
|
|
|
|
## Components
|
|
- `manifest.json` — declares permissions (`storage`, `cookies`), host permissions
|
|
for `x.com` / `twitter.com`, the background service worker, content scripts, and
|
|
web-accessible resources (phenotype images).
|
|
- `background.js` — the extension's service worker.
|
|
- `content.js` + `content.css` — injected into matched pages at `document_idle`;
|
|
reads the page DOM and renders phenotype estimates.
|
|
- `data/data.js` — static dataset (location → phenotype mapping or similar), loaded
|
|
before `content.js` so its globals are available to it.
|
|
- `images/icons/` — toolbar/extension icons.
|
|
- `images/phenotypes/` (incl. `images/phenotypes/custom/`) — images shown in the
|
|
injected UI, exposed via `web_accessible_resources`.
|
|
|
|
## Data flow
|
|
1. `background.js` fetches the profile's declared "Account based in" country via
|
|
X's internal `AboutAccountQuery` API (using the `cookies` permission for auth).
|
|
2. `content.js` requests that country for the profile being viewed, with an
|
|
in-memory cache keyed by handle.
|
|
3. It maps the country to an estimate using `data/data.js` (plus hardcoded
|
|
per-handle overrides in `content.js`).
|
|
4. It renders the result into the page using `content.css` for styling and images
|
|
from `images/phenotypes/` (or `images/phenotypes/custom/` for overrides).
|
|
|
|
No external backend of our own is involved; the only network calls are to X's own
|
|
internal API, made from the background service worker.
|