npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

trophyutil

v8.0.0

Published

ESM-only TypeScript parsers and domain models for PSNProfiles trophy data

Readme

TrophyUtil

TrophyUtil is a TypeScript library for parsing, modeling, and transforming PSNProfiles ("PSNP") trophy data.

It was built as a shared domain layer for a trophy-data ecosystem: browser extensions/userscripts that enhance PSNP pages, and backend scraping jobs that normalize site HTML for storage and analysis. The package keeps brittle DOM selectors and PSNP types and logic in one tested place.

Features

  • ESM-only npm package with generated TypeScript declarations and explicit subpath exports.
  • Dependency-free runtime: browser callers provide the real DOM, Node callers provide a DOM implementation such as jsdom.
  • Parsers for games, DLCs, trophy lists, trophies, and series pages.
  • Strong domain types for PSNP entities, like: GameListing, PlayableGame, GamePage, SeriesListing, SeriesPage, Trophy, and TrophyGroup.
  • Utility coverage for PSNProfiles page detection, URL parsing, trophy counts, rarity/speed conversions, UTC-safe dates, and stack labeling.
  • Optional adapter types for persistence concerns such as Mongo/Mongoose document timestamps.

Installation

npm install trophyutil

TrophyUtil has no runtime dependencies. If you parse HTML in Node.js, install a DOM implementation in your application:

npm install jsdom

Usage

Browser DOM

import { GameListingParser, PsnpGameBase, getPsnpPageType } from 'trophyutil';

const pageType = getPsnpPageType(new URL(window.location.href));
const nodes = PsnpGameBase.getGameNodes(pageType, window.document);

const parser = new GameListingParser();
const games = nodes.map(node => parser.parse(node));

console.log(games[0]?.id);
console.log(games[0]?.slug);
console.log(games[0]?.trophyCount);

Node.js With jsdom

import { JSDOM } from 'jsdom';
import { GamePageParser } from 'trophyutil/parsers';

const html = await fetch('https://psnprofiles.com/trophies/2983-the-evil-within').then(response => response.text());
const dom = new JSDOM(html, { url: 'https://psnprofiles.com/trophies/2983-the-evil-within' });

const game = new GamePageParser().parse(dom.window.document);

console.log(game.name);
console.log(game.trophyGroups.flatMap(group => group.trophies).length);

Typed Parse Results

Use the tryParse parsing method if you don't want to catch errors manually:

import { GameListingParser } from 'trophyutil';

const result = new GameListingParser().tryParse(row);

if (!result.ok) {
	console.error(result.error.issues);
} else {
	console.log(result.data.name);
}

Package Exports

Several subpath exports are available:

import { GameListingParser } from 'trophyutil';
import type { GameListing } from 'trophyutil/models';
import { parseNumber, labelStacks } from 'trophyutil/util';
import type { GameDocument } from 'trophyutil/adapters';

License

MIT