How I verified 23 Reddit build links with the app's own share-code decoder

How I verified 23 Reddit build links with the app's own share-code decoder

calendar_today • schedule3 min read

Last month I asked players on r/Enshrouded to share their best builds for the game's 1.0 release, using a free skill planner I maintain. The plan was simple: collect the best ones into a "community builds" page. The thread got 91 comments and 23 planner links. Turning that into a page I could trust took three small pieces of code, and each one solved a problem I didn't see coming.

1. Read the thread without an API

My build server can't reach Reddit: requests from cloud IPs get a "blocked by network security" page. Instead of fighting that, I saved the thread page from my own browser and parsed the HTML. Reddit's current markup makes this easy, because every comment is a custom element with its metadata in attributes:

<shreddit-comment author="LynessaMay" score="19" depth="0"
  thingid="t1_..." permalink="/r/Enshrouded/comments/..." ...>

So the parser is a regex over those tags plus the comment body:

for m in re.finditer(r'<shreddit-comment ([^>]*)>', page):
    a = dict(re.findall(r'([\w-]+)="([^"]*)"', m.group(1)))
    # author, score, depth, permalink, then the body's planner links

One gotcha: my browser had a translation extension on, which injects translated text into the page. I strip those nodes before reading comment bodies, or every comment shows up twice in two languages.

2. Verify every build by decoding its share code

The planner stores a whole build in the URL fragment as one big mixed-radix number written in base62 (each node is a "taken?" digit, plus a rank digit only if taken). The browser decodes it with BigInt. For the community page I wanted the same check at build time, so I ported the decoder to Python, where integers are already arbitrary precision:

n = 0
for ch in code[1:]:
    n = n * 62 + B62.index(ch)

def take(radix):
    global n
    n, digit = divmod(n, radix)
    return digit

level = take(level_cap + 1)
for node in nodes:
    if take(2):
        rank = take(max_rank) + 1 if max_rank > 1 else 1
        points[area] += rank * cost

Now the static site generator decodes every community build and asserts that the level and points spent match what I recorded when I first opened the link. If a future tree change ever breaks an old code, the build fails instead of the page quietly showing a wrong build. It also gave me a free feature: a "points by area" bar for each card (Mage 143, Warrior 29, and so on), computed from the code rather than typed by hand.

The decoding also caught something I'd have missed. Three links from one commenter decoded to only 20 to 24 points, which looked broken at first. They were deliberate: the author had posted the opening 20 points of three tank routes. The page now labels those as starter routes instead of hiding them.

3. Let the app draw its own share images

The planner already has a "save as image" button that draws the tree and stats onto a canvas. Rather than build a second renderer for the page, I let Playwright press that button for each build and save the download:

await page.goto(`${ORIGIN}/skill-planner/#c=${code}`);
await page.evaluate(n => { document.querySelector('#pl-name').value = n; }, name);
const [dl] = await Promise.all([
  page.waitForEvent('download'),
  page.evaluate(() => document.querySelector('#pl-image').click()),
]);
await dl.saveAs(`${outDir}/${slug}.png`);

Two lessons from this step:

  • Don't run a local server if you don't need one. My first version started a tiny HTTP server for the built site, and the headless browser kept sending localhost requests to the outbound proxy. Routing requests for the real domain straight to files on disk (context.route(ORIGIN + '/**', ...)) removed the server and the proxy problem at once, and the page loads with its production URLs.
  • Check the output size. The canvas draws at 2x, so 16 PNGs came to 30 MB. Resizing to 1600 px wide JPEGs with Pillow brought the folder down to 2.2 MB with no visible loss for a share image.

What the page ended up being

Sixteen builds from twelve players, ranked by upvotes, each with credit, a link to the original comment, a load-in-planner button and a share image the planner drew itself. Nothing on it is typed by hand except the summary of each author's reasoning. A week in, it already gets search impressions on its own.

The general idea I'd keep: when user content arrives as links into your own app, use the app's own code to read it back, both to verify it and to render it. Here's the result if you're curious: Enshrouded community builds

Want more #webdev & #python deep dives?

Join 6,165+ developers sharing real benchmarks, code breakdowns, and projects. Free forever.

1 Comment

0 votes

More Posts

How I Built a React Portfolio in 7 Days That Landed ₹1.2L in Freelance Work

Dharanidharan - Feb 9

Short links that outlive the vendor: a newsroom URL shortener on WordPress and AWS

jaafarabazid - Nov 10

I’m a Senior Dev and I’ve Forgotten How to Think Without a Prompt

Karol Modelski - Mar 19

Stop trusting verdicts your policy no longer supports

VEACESLAV - Dec 1

TypeScript Complexity Has Finally Reached the Point of Total Absurdity

Karol Modelski - Apr 23
chevron_left
128 Points • 4 Badges
1Posts
0Comments

Related Jobs

View all jobs →

Commenters (This Week)

5 comments
5 comments
3 comments

Contribute meaningful comments to climb the leaderboard and earn badges!