A Chrome extension for Berrus RPG that tracks idle job timers, item prices, hiscores, and session statistics.
- Idle Job Timers — Live countdown timers for active jobs with desktop notifications on completion
- Price Tracker — Historical price data with min/max/current and sparkline charts for items seen in shops and the mercadillo
- Hiscore Lookup — Search the Berrus leaderboard by player name and skill category
- Session Stats — Tracks XP gains, items collected, pesetas earned/spent, combat kills/deaths, and jobs completed per session
- TypeScript (strict mode,
noUncheckedIndexedAccess) - Bun (build, test runner, package manager)
- Chrome Extension Manifest V3
- HappyDOM for DOM testing
- Bun v1.3+
- A Chromium-based browser
bun installbun run buildThe extension is output to dist/. Load it in Chrome via chrome://extensions → "Load unpacked" → select the dist/ directory.
bun run build:watchRebuilds automatically on file changes in src/.
bun run build -- --prodEnables minification and strips console.log calls.
| Command | Description |
|---|---|
bun run build |
Bundle the extension to dist/ |
bun run build:watch |
Build with file watching |
bun run typecheck |
TypeScript type checking |
bun run lint |
ESLint |
bun run lint:fix |
ESLint with auto-fix |
bun run format:check |
Prettier format check |
bun test |
Run all tests |
src/
├── background/ Service worker — message routing, alarms, notifications, session management
├── content/ Content scripts — DOM extraction (jobs, prices), network interception, session tracking
├── popup/ Extension popup — 4-tab UI (timers, prices, hiscores, session)
├── types/ Shared type definitions (Result, messages, storage schema, domain types)
├── utils/ Shared utilities (storage, alarms, DOM helpers, type guards, logger)
└── test-utils/ Test infrastructure (Chrome API mock, fixture builders)
public/
├── manifest.json Chrome Extension Manifest V3
└── icons/ Extension icons (16, 48, 128)
scripts/
└── build.ts Custom Bun-based bundler (4 entry points, static asset copying)
The extension uses Manifest V3 with four entry points:
- Background service worker (
background.js) — Handles all message routing, chrome alarm timers, notifications, session state, and hiscore fetching via a central message handler. - Content script (
content.js) — Observes the Berrus DOM for jobs, prices, and session events. Sends structured messages to the background worker. - Interceptor (
interceptor.js) — Runs in theMAINworld atdocument_startto interceptfetch/XHRresponses from the Berrus API before the page processes them. - Popup (
popup.js) — Read-only UI that queries the background worker for current state and renders four tabs: Timers, Prices, Hiscores, and Session.
Uses a Result<T, E> pattern for all fallible operations. Functions return { ok: true, value } or { ok: false, error } instead of throwing.
Storage, alarms, and notifications use a port pattern — each module defines an interface (e.g. ChromeStoragePort) with a default implementation that wraps the Chrome API, allowing tests to inject in-memory fakes.
bun test133 tests across 14 files covering:
- Integration tests — Full message → storage → response pipeline, alarm handling, session lifecycle
- Unit tests — Hiscore HTML parsing, notification service, install handler, content script extractors
- Type/utility tests — Result type, type guards, time formatting, DOM builder
Tests use an in-memory Chrome API mock (src/test-utils/chrome-mock.ts) and HappyDOM for DOM operations.
| Permission | Purpose |
|---|---|
storage |
Persist job timers, price history, session |
alarms |
Schedule notifications for job completion |
notifications |
Desktop alerts when idle jobs finish |
Host permission: https://www.berrus.app/*