You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Detects the product page via the registered SiteAdapter
Extracts the EAN barcode depending on the strategy
Fetches product data from the OFF Canada API
Mounts a Shadow DOM UI in the bottom of the page.
Badge Fields
Field
Details
Sodium
% Daily Value bar (Health Canada: 2400 mg DV)
Sugars
% Daily Value bar (100 g DV)
Saturated Fat
% Daily Value bar (20 g DV)
Nutri-Score
A → E
NOVA group
1 → 4
Eco-Score
A → E
Badge States
State
Trigger
Loading
Shown immediately while API call is in flight
Found
Product data returned from OFF
Not Found
No barcode on page, or product not in OFF database
Flow
flowchart TD
A[Product Page] --> B[Content Script]
B --> C{Adapter}
C -->|DOM barcode| D[Metro / Super C / Food Basics]
C -->|Network Hooking| E[Loblaws]
D & E --> F[fetchProduct]
F --> G[OFF SDK]
G --> H[BadgeBuilder]
H --> I[Floating Bar]
Site Adapter pattern — each supported site implements a SiteAdapter with isProductPage(), extractBarcode(),. Adding a new site means one new adapter file.
BadgeBuilder pattern — badge construction is handled by a BadgeBuilder class that assembles sections (withNutrients(), withScores(), withAllergens(), etc.) before calling .build().
File Structure
estore-extension/
entrypoints/
content/
index.ts ← entry — detects product page, runs adapter
adapters/
metro.ts ← Metro adapter
superc.ts ← Super C adapter (Metro banner)
types.ts ← SiteAdapter interface
registry.ts ← getAdapter()
utils.ts ← shared barcode extraction utilities
ui/
BadgeBuilder.ts ← badge assembly
badge.css ← shadow DOM scoped styles
states/
full.ts
loading.ts
notFound.ts
api/
client.ts ← OFF API fetch
wxt.config.ts
Local Setup
git clone https://github.com/offCanada/NutriGlance.git
cd NutriGlance
npm install
Scripts
Command
Description
npm run dev
Dev build (Chrome)
npm run dev:firefox
Dev build (Firefox)
npm run build
Production build (Chrome)
npm run build:firefox
Production build (Firefox)
npm run zip
Package for Chrome Web Store
npm run zip:firefox
Package for Firefox Add-ons
npm run compile
TypeScript type check only
OFF API Reference
GET https://world.openfoodfacts.org/api/v0/product/{barcode}.json
Response: { status: 1, product: { ... } } // status 0 = not found