diff --git a/scripts/check-dead-html-visual.mjs b/scripts/check-dead-html-visual.mjs new file mode 100644 index 00000000..aef665dc --- /dev/null +++ b/scripts/check-dead-html-visual.mjs @@ -0,0 +1,96 @@ +import { chromium } from 'playwright'; +import sharp from 'sharp'; +import { mkdirSync, writeFileSync } from 'node:fs'; +import { resolve } from 'node:path'; + +const [beforeUrl, afterUrl] = process.argv.slice(2); +if (!beforeUrl || !afterUrl) { + console.error('Usage: node scripts/check-dead-html-visual.mjs '); + process.exit(2); +} + +const routes = [ + '/', '/shop', '/shop/comma-four', '/shop/chestnut', '/shop/body', + '/shop/comma-four-trade-in', '/vehicles', '/openpilot', '/setup', + '/support', '/jobs', '/connect', '/media', '/terms', '/neurips.html', + '/leaderboard.html', '/harness-parts.html', +]; +const viewports = [390, 1440]; +const outputDirectory = resolve('/tmp/dead-html-visual'); +const browser = await chromium.launch({ headless: true }); +const failures = []; +mkdirSync(outputDirectory, { recursive: true }); + +async function capture(url, route, width) { + const page = await browser.newPage({ + viewport: { width, height: 900 }, + deviceScaleFactor: 1, + reducedMotion: 'reduce', + }); + + await page.addInitScript(() => { + const fixedTime = Date.parse('2026-11-01T00:00:00Z'); + Date.now = () => fixedTime; + }); + await page.route('**/*', (request) => { + const requestHost = new URL(request.request().url()).hostname; + return requestHost === '127.0.0.1' || requestHost === 'localhost' + ? request.continue() + : request.abort(); + }); + + const response = await page.goto(new URL(route, url).href, { + waitUntil: 'domcontentloaded', + timeout: 30_000, + }).catch(() => null); + await page.evaluate(() => { + document.querySelectorAll('img[loading="lazy"]').forEach((image) => { + image.loading = 'eager'; + }); + }); + await page.waitForFunction( + () => [...document.images].every((image) => image.complete), + null, + { timeout: 5_000 }, + ).catch(() => {}); + await page.evaluate(() => document.fonts.ready); + await page.addStyleTag({ + content: 'video{visibility:hidden!important}*,*::before,*::after{animation:none!important;transition:none!important;caret-color:transparent!important}', + }); + await page.waitForTimeout(500); + const image = await page.screenshot({ fullPage: true, animations: 'disabled' }); + await page.close(); + return { image, status: response?.status() ?? null }; +} + +try { + for (const width of viewports) { + for (const [index, route] of routes.entries()) { + const before = await capture(beforeUrl, route, width); + const after = await capture(afterUrl, route, width); + const beforePath = resolve(outputDirectory, `before-${width}-${index}.png`); + const afterPath = resolve(outputDirectory, `after-${width}-${index}.png`); + writeFileSync(beforePath, before.image); + writeFileSync(afterPath, after.image); + + const a = await sharp(before.image).raw().toBuffer({ resolveWithObject: true }); + const b = await sharp(after.image).raw().toBuffer({ resolveWithObject: true }); + const matches = a.info.width === b.info.width + && a.info.height === b.info.height + && a.data.equals(b.data) + && before.status === 200 + && after.status === 200; + + if (!matches) failures.push({ width, route, beforeStatus: before.status, afterStatus: after.status }); + console.log(`${width}px ${route}: ${matches ? 'MATCH' : 'DIFF'}`); + } + } +} finally { + await browser.close(); +} + +console.log(`Compared ${routes.length * viewports.length} pages; ${failures.length} mismatches.`); +if (failures.length) { + console.error(JSON.stringify(failures, null, 2)); + process.exitCode = 1; +} diff --git a/src/app.html b/src/app.html index b023fdcf..39dcdf84 100644 --- a/src/app.html +++ b/src/app.html @@ -44,11 +44,6 @@ - - - comma.ai — make driving chill diff --git a/src/lib/components/HomeHeroOverlay.svelte b/src/lib/components/HomeHeroOverlay.svelte index 99edc07a..530cc6c3 100644 --- a/src/lib/components/HomeHeroOverlay.svelte +++ b/src/lib/components/HomeHeroOverlay.svelte @@ -111,7 +111,6 @@ try risk-free for 30 days - diff --git a/src/lib/components/Product.svelte b/src/lib/components/Product.svelte index dffdadae..48b22e59 100644 --- a/src/lib/components/Product.svelte +++ b/src/lib/components/Product.svelte @@ -24,6 +24,7 @@ export let disableBuyButtonText = null; export let hideOutOfStockVariants = false; export let hideVariantImage = false; + export let hideDefaultShippingNote = false; export let scrollProductImages = false; export let inlineMobileTitlePrice = false; export let previousPrice = null; @@ -191,15 +192,17 @@ > {addToCartLabel} - - - {#if product?.freeRush} - Free Rush (UPS 2nd Day Air) shipping. $30 flat rate internationally. - {:else} - Free US shipping, $30 flat rate internationally. - {/if} - - + {#if !hideDefaultShippingNote} + + + {#if product?.freeRush} + Free Rush (UPS 2nd Day Air) shipping. $30 flat rate internationally. + {:else} + Free US shipping, $30 flat rate internationally. + {/if} + + + {/if}
diff --git a/src/lib/components/ProductDescriptions/CommaFour.svelte b/src/lib/components/ProductDescriptions/CommaFour.svelte index 549892c1..0ffd2299 100644 --- a/src/lib/components/ProductDescriptions/CommaFour.svelte +++ b/src/lib/components/ProductDescriptions/CommaFour.svelte @@ -154,8 +154,7 @@ -
+ disableBuyButtonText={disableBuyButtonText} hideDefaultShippingNote={true}>
{#if referralCode} diff --git a/src/lib/components/SetupStep.svelte b/src/lib/components/SetupStep.svelte index 452b2413..b2b307cf 100644 --- a/src/lib/components/SetupStep.svelte +++ b/src/lib/components/SetupStep.svelte @@ -10,9 +10,7 @@
{#if images.length > 0}
- {#if images.length > 0} - {header - {/if} + {header {#each images.slice(1) as img} {header {/each} diff --git a/static/neurips.html b/static/neurips.html index 40f3a24e..70df47bf 100644 --- a/static/neurips.html +++ b/static/neurips.html @@ -169,14 +169,12 @@

5 Research rump talks

- tinygrad: the fastest growing neural network framework [4].

- Example figure
Figure 2: comma four exploded view.
- Example figure
Figure 3: stack plot of tinygrad lines of code over the years. @@ -185,7 +183,6 @@

5 Research rump talks

-
-

References