Browser extension for a friends-optimal Krillion leaderboard
Files
amusingimpala.com
amusingimpala.com
amusingimpala.com
trunk Default
  • TypeScript 59%
  • Nix 23%
  • CSS 12%
  • HTML 6%
README.md

WARNING: This is heavily LLM-ware. I tried to make decent steering decisions, and the code should and appears to not break anything, but I cannot make any guarantees. Caveat emptor.

Frillion #

A Chrome and Firefox extension that shows the best combined Krillion score for you and your friends, in a toolbar popup.

Scoring #

For each question, Frillion takes the highest available score across you and your friends. The sum of those scores is the team score.

Each question's points are divided equally among the players tied for its best score. For example, if John and Jill score 85 and Jake scores 60, the team receives 85 points; John and Jill contribute 42.5 each. The question breakdown lists the winning players and their answers.

Players without available results are excluded. Contributions are calculated at full precision but displayed rounded to whole points. Displayed contributions may therefore not sum exactly to the team score.

Build #

Requires Nix with flakes enabled:

nix build

The default package, also available as nix build .#frillion, produces a directory containing symlinks to two unsigned extension archives:

  • result/frillion-chrome.zip
  • result/frillion-firefox.zip

Each browser is also a distinct package whose output is the ZIP file itself:

nix build .#frillion-firefox  # result points directly to the Firefox ZIP
nix build .#frillion-chrome   # result points directly to the Chrome ZIP

To keep both individual build links with recognizable archive names:

nix build .#frillion-firefox --out-link frillion-firefox.zip
nix build .#frillion-chrome --out-link frillion-chrome.zip

The browser-loading instructions below use the combined nix build layout.

The flake uses callPackage to load package.nix, a browser-parameterized stdenvNoCC.mkDerivation with standard build, check, and install phases. Tests run as part of each browser package's build. TypeScript is strictly type-checked and compiled to JavaScript before packaging; no bundler or npm install is needed. Only the manifest, TypeScript configuration, extension sources, and tests are included in the derivation's source; local authentication fixtures are excluded. Archive timestamps are normalized for reproducible output.

Load in a browser #

Firefox #

  1. Open about:debugging#/runtime/this-firefox.
  2. Click Load Temporary Add-on….
  3. Select result/frillion-firefox.zip directly—no extraction needed.

Firefox normally distributes extensions as .xpi files, which are ZIP archives with a different extension. Temporary add-ons are removed when Firefox restarts. Permanent installation in standard Firefox requires Mozilla signing; this project does not sign or publish extensions.

Chrome #

  1. Extract result/frillion-chrome.zip into a folder outside the Nix store.
  2. Open chrome://extensions and enable Developer mode.
  3. Click Load unpacked and select the extracted folder.

Use #

Sign in to Krillion, keep a Krillion page active, and click Frillion's toolbar icon. If necessary, find or pin it through your browser's extensions menu.

The popup refreshes whenever it opens. Use Refresh to reload scores without closing it. Expand Best scores by question to see the winning answers and individual shares.

Each friend starts checked. Uncheck a friend to exclude their scores from the team score, contributions, and question breakdown; their row stays visible so you can re-enable them. Your own scores always count. Changes recalculate immediately without another API request. Selections survive manual refreshes but reset when the popup is closed.

Frillion only works while the active page is on https://krillion.io. If results are locked or unavailable, it displays a message instead of a score. If authentication fails, reopen Krillion, sign in again, and refresh.

Authentication and privacy #

On each refresh, Frillion reads the current Firebase access token from Krillion's IndexedDB and uses it to request https://krillion.io/api/friends. The token stays inside the injected function on the Krillion tab; it is not returned to the popup, logged, or saved in extension storage.

The extension uses only the activeTab and scripting permissions. It does not modify the webpage, maintain historical results, independently refresh credentials, or send data to a separate service.

Files under examples/ are local development fixtures and are not included in either extension archive. Authentication fixtures can contain sensitive credentials; do not share them.

Development and tests #

Extension code lives in src/*.ts; tsconfig.json enables strict checking. Shared API and scoring types are in src/types.ts, with the browser API surface used by the extension declared in src/browser.d.ts. Type-only imports are erased, and the ZIPs contain only the compiled JavaScript and browser assets.

nix develop
# Type-check without generating files:
tsc --noEmit
# Compile to build/ and run the JavaScript tests against that output:
tsc
node --test tests/*.test.mjs

Format all maintained source files with nix fmt (or treefmt inside nix develop). treefmt-nix runs:

  • nixfmt for Nix formatting.
  • deadnix and statix for unused Nix bindings and Nix code improvements.
  • Prettier for TypeScript, JavaScript tests, HTML, CSS, JSON, and Markdown.

Generated files, local credential fixtures in examples/, and flake.lock are excluded. Formatting is also checked by nix flake check.

To build and test through Nix:

nix flake check

Tests cover scoring, tied contributions, missing results, origin restrictions, and authentication handling using synthetic credentials. They do not replace live testing in Chrome and Firefox.

See GLOSSARY.md for scoring terminology.