Utility scripts for producing clean, transparent-background screenshots of GitHub pull-request conversations using Puppeteer. Two variants are provided: a lightweight capture for public pages and a session-aware capture that preserves the merge box.
- Node.js 18+
- Google Chrome or Chromium (bundled with Puppeteer)
- Optional: a GitHub account to authenticate when using the merge-aware flow.
Install dependencies once:
npm install- Entry point:
capture-pr-comments.run. - Captures the entire discussion area (
#discussion_bucketor.js-discussion) with a forced light theme and transparent outer chrome. - Key helpers include
capture-pr-comments.getPrUrlfor CLI overrides,capture-pr-comments.adjustViewportToContent, andcapture-pr-comments.captureDiscussionScreenshot. - Customize visuals via
capture-pr-comments.CUSTOM_CSS.
Run against any PR:
node capture-pr-comments.js https://github.com/owner/repo/pull/123If no URL is provided, it defaults to the example PR inside the script.
- Entry point:
capture-pr-comments-with-merge.run. - Stores a persistent Chromium profile under
user_data/to keep you logged in. - Ensures the tab bar and merge box are included by expanding the clip rectangle in
capture-pr-comments-with-merge.captureCombinedArea. - Handles login detection through
capture-pr-comments-with-merge.performLoginand theme prep viacapture-pr-comments-with-merge.preparePageForCapture. - Styling tweaks live in
capture-pr-comments-with-merge.CUSTOM_CSS.
Usage:
node capture-pr-comments-with-merge.js https://github.com/owner/repo/pull/123On first run you will be prompted to log in manually; subsequent executions reuse the session.
pr-comments.png— screenshot produced by the lightweight script.pr-comments-with-merge.png— screenshot including tabs and merge box.
Both renders use transparent backgrounds so they can be overlaid onto slides or documents.
- Increase viewport height limits via
MAX_VIEWPORT_HEIGHTin capture-pr-comments.js orCONFIG.maxViewportHeightin capture-pr-comments-with-merge.js when dealing with long threads. - Adjust
CONFIG.preThemeDelay/CONFIG.postStyleDelayin capture-pr-comments-with-merge.js if styles apply too early or late on slower networks. - The
.gitignorealready omitstemp/anduser_data/; keep screenshots or session files there to avoid accidental commits.