Put it on your site

One small script and one tag. It reads your newest earworm straight from your Bluesky account, so it changes by itself when you set a new one.

The short version

<script type="module" src="https://latestearworm.com/embed.js"></script>
<latest-earworm handle="you.bsky.social"></latest-earworm>

If you are signed in, your own page has this ready to copy with your handle filled in.

What it looks like

This is the real thing, restyled to match this site:

Nothing to show right now.

Options

AttributeWhat it does
handleThe Bluesky handle whose earworm to show.
didThe account’s permanent ID, in place of handle. It saves one lookup and keeps working if the handle changes.
show-expiredKeep showing the last earworm after it is more than a week old. Without this, the element shows nothing once the earworm expires.
playerAdd a play button. The music service’s player loads only when someone presses it.

Anything you put inside the tag is shown when there is no earworm to display:

<latest-earworm handle="you.bsky.social">
  Nothing stuck in my head right now.
</latest-earworm>

Making it match your site

It takes its font and text colour from the page around it. These custom properties change the rest:

PropertyChanges
--earworm-accentLink colour and the bar beside the note
--earworm-backgroundCard background
--earworm-colorText colour
--earworm-borderCard border, for example 2px solid black
--earworm-radiusCorner rounding
--earworm-padding, --earworm-gapSpacing
--earworm-art-sizeSize of the cover artwork

For anything else, each piece can be styled by name with ::part(). The names are card, art, body, label, track, artist, note, player, button, frame, links, link and credit.

latest-earworm {
  --earworm-accent: crimson;
  --earworm-radius: 0;
}
latest-earworm::part(track) {
  font-size: 1.5rem;
}

Without the component

Earworms are public records, so you can read one yourself with three requests and build whatever you like, in the browser or when your site is built.

  1. Turn the handle into an account ID:
    https://public.api.bsky.app/xrpc/com.atproto.identity.resolveHandle?handle=HANDLE
  2. Find the account’s server, listed as #atproto_pds:
    https://plc.directory/ACCOUNT_ID
  3. Ask that server for the newest earworm:
    SERVER/xrpc/com.atproto.repo.listRecords?repo=ACCOUNT_ID&collection=com.latestearworm.earworm&limit=1

Each record has trackName, artists, links and createdAt, and may have releaseName, artworkUrl, note and post. A record is whatever its owner saved, so treat every field as untrusted text and check that links start with https://.

Good to know