Media-collector bookmarklet (human-side forager) (Wildfire Forager)

**Note** from Bead: Wildfire Forager · [canonical source](https://redfish.acequia.io/guerin/.agents/5b518c35-2ce7-474a-a5a8-ec83e2fd0e82/2026-06-21/notes/03-media-collector-bookmarklet.md) · session 2026-06-21 · discussion: Talk: Wildfire Forager

Built 2026-06-21. Lives in this bead at [`repo/`](https://redfish.acequia.io/guerin/.agents/5b518c35-2ce7-474a-a5a8-ec83e2fd0e82/repo/) under its own git (in-bead git discipline). It is the **human / browser-walking** arm of the forager pattern: where `wildcad` subscribes a *dispatch* feed and EGP forages an *authoritative product*, this lets a **person** forage the open web — checkbox the images/videos on any page and log them into a named collection (a YouTube-playlist gesture).

## Architecture (copied from the EGP mission-browser, `35e928bc`) - A `javascript:` **loader** injects an **external** `collector.js` hosted in this bead, so the script can be updated without re-installing the bookmarklet. Same pattern + landing page (`collect.html`) as mission-browser's `mission-browser.html`. - Storage reuses mission-browser's driver shape — **`FSA-local | WebDAV+Bearer`**, path is the address, backend swappable (note 01 of `35e928bc`; the StorageLocation reframe in stac-manager bead `b73189b7` note 01).

## The new piece: bead-origin iframe + postMessage The bookmarklet runs on **arbitrary origins**. FSA directory handles and IndexedDB are **per-origin**, so durable state can't live in the host page or it fragments per-site and the folder grant is lost on navigation. Fix: - The host panel embeds an **iframe served from this bead** (`collector-frame.html`, origin `redfish.acequia.io`). Collections, WebDAV config, and the FSA handle all live in the bead origin's IndexedDB — one store regardless of host page. - Split of labor: - **host (`collector.js`)** — scan `<img>/<video>`, overlay checkboxes, filter UI (min rendered size + JPG/PNG/MP4/video/other), draggable panel, relay selection. - **iframe (`collector-frame.html`)** — collections list, destination (FSA folder picker / WebDAV creds), `<collection>.json` read-append-write, status back. - **postMessage**: host → iframe `{selection, pageUrl, pageTitle, items}` (stages a *pending* selection only); iframe → host `{ready|status|saved}`. Host validates `event.origin`; iframe never writes without an in-frame **Log selected** click, so a hostile parent can at most pre-fill a selection the user must confirm.

## What it writes **Links, not bytes** (the "managing links of URIs" frame, stac-manager `b73189b7` note 03). `<collection>.json` = `{type:'acq.collection', name, created, updated, items:[{pageUrl, pageTitle, savedAt, media:[{url,type,poster,w,h,alt}]}]}`. Re-saving a name appends one item per page.

## Caveats (full list in `repo/README.md`) - **FSA handles can't go in `localStorage`** (string-only); IndexedDB is the only correct store — done. Stephen's "save to localStorage" intent is honored via IndexedDB + permission re-query on reload. - **FSA inside a cross-origin iframe** may be blocked by some browsers (picker needs delegated activation); WebDAV is the always-works path, same-origin popup picker the fallback. - WebDAV is bearer-only today (→ `acequia.keys` attenuated capability later); destination server must CORS-allow PUT/GET+Authorization from `redfish.acequia.io`. - Framing: `redfish.acequia.io` must allow this path to be iframed (no `X-Frame-Options: DENY`). Verify on first deploy.

## Status / next - v0 committed in `repo/` (one commit). **Not yet `/bead-sync`'d** — the bookmarklet's `collector.js` / iframe URLs only resolve once the bead is pushed to the canonical URI. Sync, then load `collect.html` and smoke-test on a media-heavy page. - Relation: this is the concrete build of the social-foraging "save to a collection" surface ([`d2798c01`](https://redfish.acequia.io/guerin/.agents/d2798c01-dce5-412a-8be7-b85806f72214/)); collections conform toward the catalog substrate ([`90f902e0`](https://redfish.acequia.io/guerin/.agents/90f902e0-2e45-4aa1-b998-918ca3688e94/)).

## References (bead cross-links) - Bead: Social Foraging · [canonical](https://redfish.acequia.io/guerin/.agents/d2798c01-dce5-412a-8be7-b85806f72214/) - Bead: Catalog · [canonical](https://redfish.acequia.io/guerin/.agents/90f902e0-2e45-4aa1-b998-918ca3688e94/)