Skip to content

6k2/ShoppingCopilot

Repository files navigation

Shopping Copilot

Shopping Copilot is a Chromium Manifest V3 extension built as an Analysis of Algorithms project.

The production flow is intentionally simple:

Right-click Amazon product -> extract product data -> search Mercado Libre -> rank offers -> show best matches

The academic flow adds a Mock Mode that runs the same ranking algorithm over a simulated dataset of 1,000,000 Mercado Libre-style offers and shows benchmark charts generated with Matplotlib.

Main Features

  • Chrome/Chromium MV3 extension.
  • Context menu action: Shopping Copilot.
  • Native side panel optimized for a narrow browser panel.
  • Production Mode:
    • extracts product title, price, image, and URL from Amazon product pages or listing cards.
    • opens an inactive Mercado Libre results tab.
    • scrapes visible offer cards from Mercado Libre Colombia.
    • ranks the scraped offers with the project ranking algorithm.
  • Mock Mode:
    • uses a simulated dataset with 1,000,000 realistic offers.
    • runs benchmarks with input sizes calculated from the dataset size, for example 1,000, 5,000, 10,000, 25,000, 50,000, 100,000, 250,000, 500,000, and 1,000,000.
    • opens an analysis popup with runtime and O(n log n) reference charts.
  • Single focused production flow with no backend server or external scraping service.

Algorithm

The main algorithm lives in:

src/core/ranking.ts

It receives:

  • one detected Amazon product.
  • a list of Mercado Libre offers.
  • a result limit.

It performs:

  1. Text normalization and similarity scoring.
  2. Price relevance scoring.
  3. Small bonus for free shipping.
  4. Filtering of weak matches.
  5. Explicit Merge Sort by score descending and price ascending.
  6. Final top-k selection.

Complexity:

Text comparison: O(n * m)
Merge Sort:      O(n log n)
Total:           O(n * m + n log n)
If m is bounded: O(n log n)
Space:           O(n)

Where:

  • n is the number of offers.
  • m is the average product-title length.

Project Structure

public/
  icons/                 Extension icons
  analysis/              Matplotlib PNG charts used by analysis popup

scripts/
  build-extension.mjs    Builds background/content scripts and copies extension assets
  generate_algorithm_charts.py

src/
  analysis/              Algorithm-analysis popup UI
  background/            MV3 service worker and extension orchestration
  content/               Amazon extraction and Mercado Libre result scraping
  core/                  Ranking algorithm, benchmark, money/text/storage/types
  mock/                  Simulated offer dataset for Mock Mode
  panel/                 Extension side panel UI

analysis.html            Vite entry for analysis popup
panel.html               Vite entry for side panel
public/manifest.json     Chrome extension manifest

Requirements

  • Node.js 18 or newer.
  • npm.
  • Python with Matplotlib only if charts need to be regenerated.

Install

npm install

Generate Algorithm Charts

Charts are already included in public/analysis, but they can be regenerated with:

npm run charts

If Matplotlib is missing:

python -m pip install matplotlib

Build

npm run build

The production extension is generated in:

dist/

Load In Chrome

  1. Open chrome://extensions.
  2. Enable Developer mode.
  3. Click Load unpacked.
  4. Select the dist folder.

Use Production Mode

  1. Open an Amazon product page or Amazon search/listing page.
  2. Right-click the exact product title, image, or card.
  3. Choose Shopping Copilot.
  4. The side panel opens and shows ranked Mercado Libre offers.

Use Mock Mode

  1. Open the side panel.
  2. Switch from Production to Mock.
  3. Click Run benchmark.
  4. Click Open analysis to view the benchmark table and charts.

Useful Commands

npm run build
npm run typecheck
npm run lint
npm run charts

Delivery Notes

  • node_modules/ and dist/ are ignored by Git.
  • To submit source code, include the project files except node_modules/.
  • To submit a ready-to-load extension, run npm run build and include the generated dist/ folder.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors