39227-vm/LOCAL_SCREENSHOT_EXTENSION.md
2026-02-10 16:17:02 +01:00

43 lines
1.2 KiB
Markdown

# Local Chrome Screenshot Extension (Unpacked)
This is a local-only setup (no publishing) that:
1. Captures the visible tab as a PNG from a Chrome extension popup.
2. Sends it to a local HTTP server on `127.0.0.1`.
3. Extracts simplified page content (text + a pruned “content tree”) from the active tab.
4. The server saves it into `./screenshots/` and optionally runs a local script.
## 1) Start the local server
From the project root:
```bash
python3 tools/local_screenshot_bridge.py --port 8765 --out-dir screenshots --run bash scripts/on_screenshot.sh
```
Notes:
- The server listens on `http://127.0.0.1:8765/screenshot`.
- If you omit `--run ...`, it will only save files.
- If `--run ...` is set, it appends two args to the command:
- `<png_path>` then `<meta_path>`
## 2) Load the extension (unpacked)
1. Open Chrome: `chrome://extensions`
2. Enable "Developer mode"
3. Click "Load unpacked"
4. Select: `chrome_screenshot_ext/`
## 3) Use it
1. Click the extension icon.
2. Confirm the endpoint is `http://127.0.0.1:8765/screenshot`.
3. Click "Capture".
Saved files land in `screenshots/`:
- `YYYYMMDDTHHMMSSZ-<title-slug>.png`
- `YYYYMMDDTHHMMSSZ-<title-slug>.json`
- `YYYYMMDDTHHMMSSZ-<title-slug>.content.json`