defuddle icon indicating copy to clipboard operation
defuddle copied to clipboard

Substack: post data is not read from the new preloads-json script

Open kryzhovnik opened this issue 2 weeks ago • 0 comments

SubstackExtractor.extractPreloadData does not find the post data on current Substack post pages, so the extractor falls back to the DOM for metadata. The visible effect is that published loses its time.

What changed on Substack

extractPreloadData looks for a script that contains both window._preloads and body_html, and reads the string inside JSON.parse("…"). It then takes feedData.initialPost.post.

Post pages now ship the data in a separate JSON script:

<script id="preloads-json" type="application/json">{…}</script>
<script>window._preloads = JSON.parse(document.querySelector('script#preloads-json[type="application/json"]').textContent)</script>

The post is at the top-level post key (post.title, post.subtitle, post.post_date, post.body_html, post.publishedBylines). There is no feedData.initialPost.

So extractPreloadData returns null. The page still has div.body.markup, so the content is extracted, and the metadata comes from the fallbacks (og: tags, the byline date).

Reproduce

curl -sL -A "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36" \
  https://on.substack.com/p/your-substack-now-with-more-ways -o post.html

Run Defuddle (main at 3e8bde9, linkedom) on post.html with that URL (page fetched on 2026-11-13):

actual in preloads-json
extractorType substack
published 2026-11-12T00:00:00+00:00 post.post_date = 2026-11-12T17:31:44.927Z
description from og:description post.subtitle (different text on this post)

Not checked

  • Whether any Substack page still uses the old inline JSON.parse("…") shape with feedData.initialPost.post. With curl, https://substack.com/home/post/p-<id> redirects to the publication's post page, so I could not get the app page.
  • Whether a page without div.body.markup still exists. On such a page the body_html fallback would also not run.

Possible fix

In extractPreloadData, read script#preloads-json first and take post (keep the current path for the old shape).

kryzhovnik avatar Nov 13 '26 10:11 kryzhovnik