Skip to content

Investigate: browser extension for one-click tracking #9

Open

Description

@ophionos

Explore a browser extension that adds the current page as a tracked product through the API (bearer API keys already exist).

Questions to answer:

  • Which browsers, and what is the maintenance cost?
  • Can it reuse the existing add-product endpoint unchanged?

Findings

Add-product endpoint: usable unchanged for an MVP. A bearer key with the write scope works, and the extension must send X-Requested-With (CsrfMiddleware). CORS does not apply: a background-script request with host permission for the Ophi origin bypasses it in both Chrome and Firefox. The gaps it does have (exact-string duplicate check, 409 without the product ID, no lookup by URL) are tracked separately in #49, which this depends on.

Scope change: the extension also feeds price observations, not just adds products. It is manual crawling with the user's own browser, which covers stores the server cannot reach. That needs the server work in Part B before the extension in Part C.

Part B — server: prices from the user's browser

The extension submits the rendered page HTML; the server parses it with the existing extractors. The extension never extracts a price itself: every price must pass PriceParser's > 0 guard (docs/agent-notes.md § Pricing), and TypeScript extraction would duplicate the store adapters.

  • Fetch-free parsing. ScrapingService.ParseWithConfigAsync already parses saved HTML (Generic scraper takes a related product's price on WooCommerce pages (pine64.com) #136), but only for an explicit StoreConfig. The main path, ScrapeProductAsync, mixes fetch and parse; its store lookup, custom selector, and generic fallback need a fetch-free entry point.
  • Per-URL check mode: Server | Browser. The stores that need this are exactly the ones whose URLs get auto-paused on AntiBot, and paused URLs are excluded from aggregation by invariant. A Browser URL is never dispatched, so it accrues no failures, backoff, or pause. One mode per URL also keeps two vantage points off one URL: mixed sources can alternate regional prices or currencies, which trips anomaly flags, currency re-anchors, PreviousPrice clears, and alert dormancy.
  • Split CheckProductPriceHandler into "obtain a ScrapingResult" and "apply a result", so the apply half has one owner. The browser path reuses the success and out-of-stock branches, not the failure branch: an unparseable or challenge page is an error returned to the extension and does not touch FailureCount, the notification latch, or backoff.
  • Store, then command. In split mode the API routes only ScrapeProductUrlCommand to the worker, and the alert and history handlers run on the worker. Persist the submitted HTML in a table and send a routed command; do not put megabytes of HTML in a message. Check the request body limit.
  • Provenance. Add a Source (server / browser) to PricePoint. RecordedAt is the server's receipt time, never a client timestamp.
  • Add from the browser. The first scrape of a product added in Browser mode uses the submitted HTML; otherwise adding a product from an unreachable store fails on its first scrape.

Part C — the extension

Browsers: Chrome and Firefox from one Manifest V3 codebase (e.g. WXT, TypeScript). WXT handles the background difference (Chrome service worker, Firefox event page). The Chrome build also runs in Edge, Brave, and Opera. Safari is out of scope (Xcode, macOS, paid developer account).

Permissions: activeTab + scripting for the current tab's URL and DOM on a click. The Ophi origin differs per install, so it is requested at runtime through optional host permissions from the options page. The key lives in storage.local, never storage.sync.

MVP:

  • Options page: server URL, API key, "test connection".
  • Toolbar button: add the current tab (POST /api/v1/products), then show pending → name and price, with a link into Ophi. For a Browser-mode URL, it submits the page HTML as an observation.
  • Clear messages for 409 (with a link, via Canonical product URLs, 409 with existing product, and lookup by URL #49), 403 (key lacks write), and 429 (ProductCreation rate limit).

Later: "already tracked" badge (via the #49 lookup; costs broader permissions), context-menu "Track this link", target price in the popup (existing create-alert endpoint), tag picker, keyboard shortcut. Automatic submission on visiting a tracked page would need per-store host permissions and sends browsing data without a click: a per-store opt-in at most.

Distribution and maintenance: the code is small (popup, options page, a few calls). The recurring cost is the stores. Firefox installs require an AMO-signed build, even self-distributed (unlisted signing), plus browser_specific_settings.gecko.id. Chrome is either a Web Store listing (one-time developer fee, review per release) or "load unpacked" in developer mode. Unlisted Firefox signing plus "load unpacked" is the cheapest path.

Open decisions

  1. Distribution: public store listings, or self-distributed builds?
  2. A narrower key scope (e.g. products:add) for the extension? A write key can also delete products. Optional, given the scope set in Investigate: account hardening (email re-verification, active sessions, 2FA) #14.

Order: #49 → Part B → Part C.

[🤖 Generated by Claude Opus 5.5]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestinvestigationIdea to explore before committing to workpriority: lowPolish or investigation; no user harm

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions