Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions scripts/newsletter/capture-flow.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,21 @@ export default async function flow({ goto, mark, page, pause, scrollTo }) {
await goto(process.env.CAPTURE_TARGET_URL);
mark('article');

// Third-party articles interrupt a scroll with a newsletter or signup modal
// (Medium does it partway down), which then sits over the body for the rest of
// the walk. Escape closes every one seen so far, and costs nothing on a page
// that has none, so it is pressed at each beat rather than only on arrival.
const dismiss = async () => {
await page.keyboard.press('Escape').catch(() => {});
await page
.locator('[aria-label="close" i], button[data-testid="close-button"]')
.first()
.click({ timeout: 700 })
.catch(() => {});
};

await pause(1600);
await dismiss();
mark('top');

const depth = await page.evaluate(() => {
Expand All @@ -36,6 +50,7 @@ export default async function flow({ goto, mark, page, pause, scrollTo }) {

if (depth > 200) {
await scrollTo(depth);
await dismiss();
await pause(1500);
mark('body');
await scrollTo(0);
Expand Down
7 changes: 7 additions & 0 deletions scripts/newsletter/capture-gifs.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,13 @@ async function capture(target, { engine, postsDir, theme, workDir }) {
'node',
[
engine,
// Headed because headless Chromium is fingerprinted and blocked outright by
// some of the sites the newsletter links, and --no-root because the engine
// otherwise loads the site root first: wasted footage the runner trims, and
// on a Cloudflare-fronted site the root-then-deep-link hop is itself what
// trips the bot check.
'--headed',
'--no-root',
'--url',
target.url,
'--flow',
Expand Down