This repo is a Cloudflare worker which can be used with a private leaderboard to provide the metadata required for a custom badge from shields.io with your Advent of Code stars earned for a given year, like this:
You will need:
- A Cloudflare account
- An Advent of Code private leaderboard
- Your
session
cookie from Advent of Code
Set the LEADERBOARD
variable to your leaderboard ID, i.e. the <id>
from your private leaderboard URL https://adventofcode.com/<year>/leaderboard/private/view/<id>
Use wrangler secret put SESSION_TOKEN
to set your token
Use wrangler dev
and test the endpoint
wrangler publish
Take your workers URL with user_id
and year
set in the query parameters, and URL encode it.
Then provide it and the url
parameter to https://img.shields.io/endpoint
Use that as the image source for your badge.
[![AoC Badge](https://img.shields.io/endpoint?url=https%3A%2F%2Faoc.your-worker-here.workers.dev%2F%3Fuser_id%3D4896%26year%3D2022)](https://adventofcode.com/)
Your session token lasts about a month, so you'll have to update that occasionally.