Skip to content

fix(substack): read post data from preloads-json script - #482

Merged
kepano merged 2 commits into
kepano:mainfrom
EnesKartal:fix/substack-preloads-json-479
Nov 18, 2026
Merged

kepano merged 2 commits into
kepano:mainfrom
EnesKartal:fix/substack-preloads-json-479

Conversation

@EnesKartal

Copy link
Copy Markdown
Contributor

Fixes #479

Changes

  • Updated SubstackExtractor.extractPreloadData() in src/extractors/substack.ts to check script#preloads-json[type="application/json"] (and script#preloads-json) first, reading data?.post ?? data?.feedData?.initialPost?.post when body_html is present, before falling back to the legacy inline window._preloads = JSON.parse("...") script.
  • Added regression tests in tests/substack-preloads.test.ts covering the new preloads-json top-level post shape, the legacy feedData.initialPost.post shape, and malformed JSON fallback.

Testing

  • npx tsc --noEmit (passed)
  • npm run build:types && npm run build:node && npm run build:js (passed)
  • npx vitest run tests/substack-preloads.test.ts tests/extractor-options.test.ts tests/extractor-attributes.test.ts tests/extractor-xss.test.ts (4 files, 38 passed)

EnesKartal and others added 2 commits November 15, 2026 04:46
Adds a poisoned body_html case to extractor-xss.test.ts and drops the redundant type selector for script#preloads-json.
@kepano
kepano merged commit 7cfa7c9 into kepano:main Nov 18, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants