Skip to content
nslukePublic

About

Project for mana pool application

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

ManaDrain

A Chrome extension that lets Magic: The Gathering players collect cards from popular MTG websites into a shopping list for Mana Pool.

Supported Sites

  • Scryfall (scryfall.com) — Card detail pages and search results
  • EDHREC (edhrec.com) — Commander recommendations and card pages
  • BotBox (botbox.dev) — Pack simulator cards
  • Mana Pool (manapool.com) — Card listings and browse pages

Features

  • Toggle buttons on card images across all supported sites — hover to show, click to add/remove
  • Floating overlay panel with your shopping list, quantity controls, and running price total
  • Live pricing from Mana Pool API with Scryfall fallback, including foil and etched variants
  • Foil support — toggle foil per card, auto-detected for foil-only printings
  • Sorting — by recently added, alphabetical, or price
  • Mass entry export — copies your list in Mana Pool format and auto-pastes into manapool.com/add-deck
  • Card links — click any card name to go directly to its Mana Pool listing
  • Card image tooltips — hover over card names to preview the card
  • Persistent storage via chrome.storage.local across sessions
  • MTG-themed UI — gold and mahogany design with Cinzel font

Screenshots

Scryfall EDHREC
Scryfall EDHREC
BotBox Menu
BotBox Menu

Installation

From Release (recommended)

  1. Download manadrain-chrome.zip (or manadrain-firefox.zip) from the latest release
  2. Unzip it to a folder on your computer
  3. Open Chrome and go to chrome://extensions/
  4. Enable Developer mode (toggle in top-right)
  5. Click Load unpacked and select the unzipped folder
  6. Visit any supported site and start collecting cards

From Source

  1. Clone this repository:
    git clone https://github.com/nsluke/manadrain.git
    cd manadrain
  2. Install dependencies and build:
    npm install
    npm run build
    This writes two unpacked extensions: dist-chrome/ and dist-firefox/.
  3. Open Chrome and go to chrome://extensions/
  4. Enable Developer mode (toggle in top-right)
  5. Click Load unpacked and select the dist-chrome/ folder

For Firefox, open about:debugging → This Firefox → Load Temporary Add-on and pick dist-firefox/manifest.json. Firefox 128 or newer is required (the BotBox integration relies on MAIN-world content scripts).

Usage

  1. Browse to any supported MTG site
  2. Hover over a card image to see the + button
  3. Click to add it to your list (click again to remove)
  4. Click the floating ⬣ button (bottom-right) to expand your shopping list
  5. Toggle foil, adjust quantities, sort your list
  6. Click Buy on TCGPlayer to copy your list and open TCGPlayer's Mass Entry page
  7. Or use Export in the popup for CSV, Forge, MTGO, XMage, Arena, or a print-and-play PDF sheet

The Copy for Mana Pool and Open Mana Pool buttons are disabled pending Mana Pool mass-entry support.

Development

npm run build          # Build both dist-chrome/ and dist-firefox/
npm run build:chrome   # Chrome only
npm run build:firefox  # Firefox only
npm run watch          # Rebuild dist-chrome/ on file changes
npm run typecheck      # Type-check without emitting
npm test               # Unit + DOM tests (fast, no browser)
npm run test:e2e       # End-to-end in real Chrome and Firefox
npm run test:all       # typecheck + unit + e2e

Testing

Three layers:

Layer Command What it covers
Unit / DOM npm test Pure logic plus content scripts against a simulated DOM. Runs the message-passing paths twice — once with Chrome's promise-based chrome.*, once with Firefox's promise browser.* + callback-style chrome.* — so cross-browser API bugs surface without a browser.
E2E Chrome npm run test:e2e:chrome Real Chromium with the extension loaded: injection, storage, badge, popup sync, print page, XSS and permission checks.
E2E Firefox npm run test:e2e:firefox Real Firefox with the extension installed as a temporary add-on: injection and the full content script → background → storage → overlay round trip.

Both E2E suites are hermetic — every request is served from a local fixture and anything escaping to the real network fails the run. Site pages are served on the real hostnames (via request interception in Chrome, a local proxy in Firefox) because the manifest only injects on those origins.

Firefox notes: extensions need the full dist-firefox build packaged as an XPI, which test:e2e:firefox does automatically. Geckodriver refuses to navigate to moz-extension:// URLs, so the popup and print pages are not driven in Firefox; their behaviour under Firefox's API shape is covered by the dual-shape unit tests instead.

After rebuilding, reload the extension in chrome://extensions/.

Architecture

src/
  service-worker.ts          # Background: message routing, storage, badge, pricing
  content-scripts/
    overlay.ts               # Shadow DOM floating panel (shared across all sites)
    scryfall.ts              # Scryfall card detection + toggle buttons
    edhrec.ts                # EDHREC card detection
    botbox.ts                # BotBox card detection (ISOLATED world)
    botbox-bridge.ts         # BotBox data bridge (MAIN world)
    manapool.ts              # Mana Pool card detection + mass entry auto-paste
  shared/
    types.ts                 # CardEntry type, ID generation, mass entry formatting
    storage.ts               # chrome.storage.local wrapper for persistent data
    manapool-api.ts          # Mana Pool + Scryfall pricing pipeline
    checkmark-state.ts       # Persistent button state for re-rendering sites
  popup/
    popup.html/ts/css        # Extension popup UI

Tech Stack

  • TypeScript
  • Chrome Extension Manifest V3
  • esbuild
  • Vitest
  • Vanilla DOM (no frameworks)

About

Project for mana pool application

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages