Project

Petbook

Share a CS2 pet’s photo book with a link. Live at petbook.win.

TypeScriptCloudflare WorkersR2D1Steam OpenIDPlaywright
Petbook viewer showing a CS2 HatchBookPetbook viewer showing a CS2 HatchBook

Problem

CS2 keeps a pet's photo book on the player's own disk, in a binary format, with no way to show it to anyone else.

What I built

Reverse-engineered the book file (a Snappy block of JPEG pages plus a protobuf with the pet's name and hatch time) and ported the game's Panorama page logic so the browser renders the exact pages, then added an owner-only editor that writes placements back in the game's own file-name tags.

Architecture

  • Cloudflare Worker (TypeScript) — upload, viewer, owner API; no server to run
  • R2 for photos and uploads, D1 (SQLite) for accounts, pages, templates and traffic counters
  • Browser-side parsing of the cloud book file and pet.bin; only pages and the pet name are sent
  • Steam OpenID sign-in with a signed cookie; strict CSP on profile pages; per-IP rate limits
  • Personal pages with templates, music, effects and per-part analytics; site-wide analytics for the owner only

Technical highlights

  • The 3D page turn, chapter bar, slot rules and photo crops match the game; text variants are chosen the same way the game does.
  • Drag-and-drop editor: Library panel, slot rules, zoom and pan sliders, layout strips; edits save in the game's file-name tag format.
  • Visitors are counted with a daily keyed hash; no IP address is stored. Bots and link-preview robots are ignored.

Impact

  • Anyone can share a book with a link; the pages render the same on a phone.
  • Runs on the free tiers of Workers, R2 and D1.