@jonandev/longbeard 0.9.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,86 @@
1
+ # Sources: what to keep, and how to get the shot
2
+
3
+ ## Thumbnails for the picker
4
+
5
+ Each picker row takes its title, thumbnail and link from the same card on the listing page, so a pick always opens the thing that was picked. Hotlink the thumbnail and never save it. Use the smallest size that still reads at about 400 px wide. The link is the item's own page, never the listing. These were checked by reading the plain listing HTML, without a login (2026-11-14):
6
+
7
+ - **Dribbble:** `dribbble-cards.mjs --picker` prints the rows.
8
+ - **Awwwards:** use `/websites/sites_of_the_day/`, which already meets the award floor. Each card's `figure-rollover__link` has the title (`aria-label`) and the site page (`/sites/<slug>`), and its image's `data-srcset` has the `thumb_440_330` size.
9
+ - **Recent:** each card's image is the poster (`…/recording/poster/640.webp`). The link next to it is labelled `View post: <title>` and goes to `/i/<id>-<slug>`.
10
+ - **Dark Mode Design:** each card is a link to the live site around an image whose `alt` is the title.
11
+ - **Wikimedia Commons:** `thumburl`, with `descriptionurl` as the link.
12
+
13
+ **siteinspire** refuses scripted requests to its listing (429), so it is not in the picker. Do not work around a site that refuses scripts. If they tick it anyway, say so, and take any siteinspire page they paste as a seed.
14
+
15
+ A source whose cards you cannot read is not in the picker. Say so under `Sources:`. Never screenshot a listing to fake one.
16
+
17
+ ## Keeping
18
+
19
+ A nominee is not a reference. Open it full size and drop anything weak before it goes on the board. A weak pass means fewer keeps, not a lower bar.
20
+
21
+ ## Galleries
22
+
23
+ - **Awwwards.** Open the site page, not the listing card. Keep Site of the Day, Month, or Year, or an Honorable Mention with overall and Design ≥ 7.5. Drop any 4s, and any gate or password wall.
24
+ - **siteinspire, Recent** (recent.design/websites). These are curated, not scored. Keep a live page with one clear idea: a crop, a component, or an arrangement. Drop generic SaaS (centred headline, three icon cards, soft gradient, Inter). On Recent, open the source URL on the item.
25
+ - **Dark Mode Design.** Only when the look is dark.
26
+ - **Muzli.** Only a way to reach the original, which then has to pass its own test.
27
+
28
+ ## Dribbble
29
+
30
+ Listing pages render in the browser, and shot pages hit human verification. Use the script on a popular listing for this year:
31
+
32
+ ```
33
+ node <skill>/scripts/dribbble-cards.mjs "https://dribbble.com/search/shots/popular/product-design?q=text+editor+screen&timeframe=year" --scrolls 4
34
+ ```
35
+
36
+ It prints `id-slug`, likes, views, designer, image URL, and title, sorted by likes. With `--picker` it prints picker rows instead (title, thumbnail, shot page, `dribbble`, designer and likes), ready to append to `candidates.tsv`. It drops shots under 100 likes (`--min-likes` changes that), and merch, CVs, worksheets, posters, logos, and tool ads by slug and title. Extend that list with `--drop "a,b"` and relax it with `--keep "a,b"`. Save the image from `cdn.dribbble.com` (`<url>?resize=1600x1200`).
37
+
38
+ - Use a category path and the form, not the word: `/product-design?q=…`, `/mobile?q=…`, `/web-design?q=…`.
39
+ - If most of what gets through is off-form, the query is wrong. Fix the query rather than scrolling further.
40
+ - A product's category can be swamped by stores. Query the thing people do with it, and `--drop` what the brief rules out.
41
+ - A thin query ignores `timeframe=year`: the shot ids show it.
42
+ - Run one query at a time. If a query returns 0 cards, retry after 8 s, then 30 s. If it is still 0, note it under `Sources:` as a possible rate limit.
43
+ - **Popular is not good.** Dribbble's popular order mixes likes with recency, so the top of a listing is often just new. Rank by likes, never by position on the page.
44
+ - **Likes grow with age.** Shot ids rise over time, so compare likes between shots of similar id. A shot whose id is far below the rest is years old: keep it only if nothing about it looks dated.
45
+ - **Judge the designer, not only the shot.** One designer with several near-identical shots in a listing is a concept studio: keep at most one of theirs.
46
+ - For the pool, the mechanical cuts are enough: off-topic, the likes floor, one per near-identical designer. At the shortlist, keep a shot when you can name its idea in one line, it stands out on likes in its own listing, and it looks current. Drop AI mush, fake browser chrome, purple-on-dark gradients, Inter everywhere, and emoji icons.
47
+ - A Dribbble illustration is imagery, never a site.
48
+
49
+ ## Cropping a downloaded image
50
+
51
+ To crop a picture you already have (a screen inside a marketing frame, a type specimen):
52
+
53
+ ```
54
+ node <skill>/scripts/capture.mjs "file://<abs path to image>" --out design-exploration/<slug>/refs/<name>.jpg --clip x,y,w,h
55
+ ```
56
+
57
+ `--clip` is in the image's own pixels.
58
+
59
+ ## Imagery
60
+
61
+ Search the subject, not a stock category. One real place or material beats a pile of similar ones. Zero imagery is a complete answer.
62
+
63
+ - **Wikimedia Commons.** Query the API with `-A "<project>-hunt/0.1"`, `prop=imageinfo&iiprop=url&iiurlwidth=1920`. Save `thumburl`. `descriptionurl` is the `link`.
64
+
65
+ ## Contact sheets
66
+
67
+ Viewing listing thumbnails is fine. It is not a capture. Build labelled grids in scratch, never under `design-exploration/`:
68
+
69
+ ```
70
+ node <skill>/scripts/contact-sheet.mjs candidates.tsv --out <scratch>/sheets # TSV: label<TAB>imageURL
71
+ ```
72
+
73
+ ## Capture a live page
74
+
75
+ Only for a keep, run from the project root:
76
+
77
+ ```
78
+ node <skill>/scripts/capture.mjs <url> --out design-exploration/<slug>/refs/<name>.jpg
79
+ ```
80
+
81
+ The script dismisses cookie banners, scrolls so reveals load, unsticks fixed headers, and takes one full-page JPEG. Node 22+ and an installed Chrome are required (set `CHROME_PATH` if Chrome is somewhere unusual). Options:
82
+
83
+ - `--review <scratch>/x.jpg` writes a readable side-by-side version of a tall page.
84
+ - `--clip-selector "main"` or `--clip x,y,w,h` crops to a type specimen.
85
+
86
+ Open the file. Delete it and run again if it repeats a band, still shows a cookie dialog, or is mostly empty. If a page will not scroll (WebGL, a locked canvas), keep one viewport and say so on the card. Never stitch screenshots.
@@ -0,0 +1,489 @@
1
+ #!/usr/bin/env node
2
+ // Full-page capture. Unsticks fixed/sticky chrome first so Chrome does not
3
+ // repeat the same fold. Node 22+. Uses an installed Chrome/Edge/Chromium.
4
+ //
5
+ // node capture.mjs <url> --out design-exploration/<slug>/refs/name.jpg
6
+ // node capture.mjs <url> --out design-exploration/<slug>/refs/name.jpg --review /tmp/name-review.jpg
7
+ // node capture.mjs <url> --out design-exploration/<slug>/refs/name.jpg --clip x,y,w,h
8
+ // node capture.mjs <url> --out design-exploration/<slug>/refs/name.jpg --clip-selector "main"
9
+ // node capture.mjs <url> --out /tmp/mobile.png --width 390
10
+ // node capture.mjs http://localhost:3000/app --out /tmp/app.png --cookie "session=abc; theme=dark" --strict
11
+ //
12
+ // A page that ends up at another address (a login, or a site's canonical
13
+ // www) is named on stderr. With --strict that is exit 1, so a 0 means the
14
+ // shot is of the page asked for.
15
+ // node capture.mjs file:///abs/path/moodboard.html --out /tmp/moodboard.jpg
16
+ // node capture.mjs file:///abs/path/shot.jpg --out design-exploration/<slug>/refs/name.jpg --clip x,y,w,h
17
+ import { spawn, execSync } from "node:child_process";
18
+ import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
19
+ import { tmpdir } from "node:os";
20
+ import { dirname, isAbsolute, join, resolve } from "node:path";
21
+
22
+ const args = process.argv.slice(2);
23
+ const flag = (name, def) => {
24
+ const i = args.indexOf(`--${name}`);
25
+ if (i === -1) return def;
26
+ const v = args[i + 1];
27
+ args.splice(i, 2);
28
+ return v;
29
+ };
30
+ const url = args[0];
31
+ const outArg = flag("out", "") || "";
32
+ const reviewArg = flag("review", "") || "";
33
+ const clipArg = flag("clip", "") || "";
34
+ const clipSelector = flag("clip-selector", "") || "";
35
+ // Sent with every request to the page's own origin, as a logged-in browser would.
36
+ const cookieArg = flag("cookie", "") || "";
37
+ const strictAt = args.indexOf("--strict");
38
+ const strict = strictAt !== -1;
39
+ if (strict) args.splice(strictAt, 1);
40
+ // Below 768 the page gets a phone viewport: mobile layout, 2x pixels.
41
+ const width = Math.round(Number(flag("width", "1440")));
42
+ if (!url || !/^(https?|file):\/\//.test(url) || !outArg) {
43
+ console.error(
44
+ 'usage: node capture.mjs <https://url | file:///path> --out design-exploration/<slug>/refs/name.jpg [--review /tmp/name-review.jpg] [--clip x,y,w,h | --clip-selector "css"] [--width 390] [--cookie "name=value; …"] [--strict]',
45
+ );
46
+ process.exit(2);
47
+ }
48
+ if (!Number.isFinite(width) || width < 200 || width > 3840) {
49
+ console.error("width must be a number from 200 to 3840");
50
+ process.exit(2);
51
+ }
52
+ const mobile = width < 768;
53
+ const height = mobile ? 844 : 900;
54
+ if (clipArg && clipSelector) {
55
+ console.error("pass --clip or --clip-selector, not both");
56
+ process.exit(2);
57
+ }
58
+
59
+ function projectRoot() {
60
+ try {
61
+ return execSync("git rev-parse --show-toplevel", { encoding: "utf8" }).trim();
62
+ } catch {
63
+ return process.cwd();
64
+ }
65
+ }
66
+
67
+ function resolveOut(path) {
68
+ if (!path) return "";
69
+ if (isAbsolute(path)) return path;
70
+ return resolve(projectRoot(), path);
71
+ }
72
+
73
+ const out = resolveOut(outArg);
74
+ const reviewOut = resolveOut(reviewArg);
75
+
76
+ function parseClip(s) {
77
+ if (!s) return null;
78
+ const parts = s.split(",").map((n) => Number(n.trim()));
79
+ if (parts.length !== 4 || parts.some((n) => !Number.isFinite(n) || n < 0)) {
80
+ console.error("clip must be x,y,w,h (non-negative numbers)");
81
+ process.exit(2);
82
+ }
83
+ const [x, y, w, h] = parts;
84
+ if (w < 1 || h < 1) {
85
+ console.error("clip width and height must be >= 1");
86
+ process.exit(2);
87
+ }
88
+ return { x, y, width: w, height: h, scale: 1 };
89
+ }
90
+
91
+ const clip = parseClip(clipArg);
92
+
93
+ function findChrome() {
94
+ const env = process.env.CHROME_PATH;
95
+ if (env && existsSync(env)) return env;
96
+ const home = process.env.HOME || process.env.USERPROFILE || "";
97
+ const local = process.env.LOCALAPPDATA || "";
98
+ const pf = process.env.PROGRAMFILES || "C:\\Program Files";
99
+ const pf86 = process.env["PROGRAMFILES(X86)"] || "C:\\Program Files (x86)";
100
+ const candidates = [
101
+ join(pf, "Google/Chrome/Application/chrome.exe"),
102
+ join(pf86, "Google/Chrome/Application/chrome.exe"),
103
+ join(local, "Google/Chrome/Application/chrome.exe"),
104
+ join(pf, "Microsoft/Edge/Application/msedge.exe"),
105
+ "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
106
+ "/Applications/Chromium.app/Contents/MacOS/Chromium",
107
+ "/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge",
108
+ join(home, "Applications/Google Chrome.app/Contents/MacOS/Google Chrome"),
109
+ "/usr/bin/google-chrome",
110
+ "/usr/bin/google-chrome-stable",
111
+ "/usr/bin/chromium",
112
+ "/usr/bin/chromium-browser",
113
+ ];
114
+ return candidates.find((path) => path && existsSync(path)) || null;
115
+ }
116
+
117
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
118
+
119
+ const exe = findChrome();
120
+ if (!exe) {
121
+ console.error("No Chrome/Edge/Chromium found. Install one or set CHROME_PATH.");
122
+ process.exit(1);
123
+ }
124
+ if (typeof WebSocket === "undefined") {
125
+ console.error("Node 22+ is required.");
126
+ process.exit(1);
127
+ }
128
+
129
+ const dir = mkdtempSync(join(tmpdir(), "hunt-chrome-"));
130
+ let proc;
131
+ const drop = () => {
132
+ try {
133
+ if (proc?.pid) process.kill(proc.pid, "SIGKILL");
134
+ } catch {}
135
+ try {
136
+ rmSync(dir, { recursive: true, force: true });
137
+ } catch {}
138
+ };
139
+ process.once("exit", drop);
140
+
141
+ proc = spawn(
142
+ exe,
143
+ [
144
+ "--headless=new",
145
+ "--remote-debugging-port=0",
146
+ `--user-data-dir=${dir}`,
147
+ "--no-first-run",
148
+ "--hide-scrollbars",
149
+ "--mute-audio",
150
+ "--force-color-profile=srgb",
151
+ `--window-size=${width},${height}`,
152
+ "about:blank",
153
+ ],
154
+ { stdio: ["ignore", "ignore", "pipe"] },
155
+ );
156
+
157
+ let buf = "";
158
+ const wsUrl = await new Promise((resolveWs, reject) => {
159
+ const t = setTimeout(() => reject(new Error("Chrome did not start")), 20000);
160
+ proc.stderr.on("data", (d) => {
161
+ buf += d.toString();
162
+ const m = buf.match(/DevTools listening on (ws:\/\/[^\s]+)/);
163
+ if (m) {
164
+ clearTimeout(t);
165
+ resolveWs(m[1]);
166
+ }
167
+ });
168
+ proc.on("exit", (code) => {
169
+ clearTimeout(t);
170
+ reject(new Error(`Chrome exited ${code}`));
171
+ });
172
+ });
173
+
174
+ const ws = new WebSocket(wsUrl);
175
+ await new Promise((res, rej) => {
176
+ ws.onopen = res;
177
+ ws.onerror = () => rej(new Error("CDP socket failed"));
178
+ });
179
+ let nextId = 1;
180
+ const pending = new Map();
181
+ ws.onmessage = (ev) => {
182
+ const msg = JSON.parse(typeof ev.data === "string" ? ev.data : Buffer.from(ev.data).toString());
183
+ if (msg.id && pending.has(msg.id)) {
184
+ const { resolve: ok, reject: bad } = pending.get(msg.id);
185
+ pending.delete(msg.id);
186
+ if (msg.error) bad(new Error(msg.error.message));
187
+ else ok(msg.result);
188
+ }
189
+ };
190
+ const send = (method, params = {}, sessionId, timeoutMs = 30000) => {
191
+ const id = nextId++;
192
+ return new Promise((resolveSend, reject) => {
193
+ const timer = setTimeout(() => {
194
+ pending.delete(id);
195
+ reject(new Error(`CDP timeout: ${method}`));
196
+ }, timeoutMs);
197
+ pending.set(id, {
198
+ resolve: (v) => {
199
+ clearTimeout(timer);
200
+ resolveSend(v);
201
+ },
202
+ reject: (e) => {
203
+ clearTimeout(timer);
204
+ reject(e);
205
+ },
206
+ });
207
+ ws.send(JSON.stringify(sessionId ? { id, method, params, sessionId } : { id, method, params }));
208
+ });
209
+ };
210
+
211
+ const { targetId } = await send("Target.createTarget", { url: "about:blank" });
212
+ const { sessionId } = await send("Target.attachToTarget", { targetId, flatten: true });
213
+ const page = (method, params, timeoutMs) => send(method, params, sessionId, timeoutMs);
214
+
215
+ await page("Page.enable");
216
+ await page("Runtime.enable");
217
+ await page("Emulation.setDeviceMetricsOverride", {
218
+ width,
219
+ height,
220
+ deviceScaleFactor: mobile ? 2 : 1,
221
+ mobile,
222
+ });
223
+ // Chrome centres an image file and shrinks it to the window. A page that holds
224
+ // it at full size from 0,0 makes --clip x,y,w,h the image's own pixels.
225
+ let target = url;
226
+ if (/^file:\/\/.*\.(png|jpe?g|webp|gif)$/i.test(url)) {
227
+ target = `file://${join(dir, "image.html")}`;
228
+ writeFileSync(join(dir, "image.html"), `<!doctype html><body style="margin:0;background:#000"><img src="${url.replace(/"/g, "%22")}" style="display:block">`);
229
+ }
230
+ if (cookieArg && /^https?:/.test(url)) {
231
+ const cookies = cookieArg
232
+ .split(";")
233
+ .map((pair) => pair.trim())
234
+ .filter(Boolean)
235
+ .map((pair) => {
236
+ const at = pair.indexOf("=");
237
+ return { name: pair.slice(0, at), value: pair.slice(at + 1), url: new URL(url).origin };
238
+ });
239
+ if (cookies.some((cookie) => !cookie.name)) {
240
+ console.error('cookie must be "name=value; name=value"');
241
+ drop();
242
+ process.exit(2);
243
+ }
244
+ await page("Network.setCookies", { cookies });
245
+ }
246
+ await page("Page.navigate", { url: target }, 40000);
247
+ await sleep(2500);
248
+
249
+ const beforeHref = (
250
+ await page("Runtime.evaluate", {
251
+ expression: "location.href",
252
+ returnByValue: true,
253
+ })
254
+ ).result.value;
255
+
256
+ await page("Runtime.evaluate", {
257
+ expression: `(() => {
258
+ const labels = /^(accept( all)?( cookies)?|agree|ok|okay|got it|allow( all)?|i understand|acepto|aceptar)$/i;
259
+ const clickable = document.querySelectorAll("button, [role=button]");
260
+ for (const el of clickable) {
261
+ const t = (el.innerText || el.textContent || "").trim().replace(/\\s+/g, " ");
262
+ if (t.length < 40 && labels.test(t)) { el.click(); break; }
263
+ }
264
+ // Strip short privacy/cookie dialogs (e.g. Google Fonts "×" banner).
265
+ const privacy = /uses cookies|privacy and google fonts|cookie settings/i;
266
+ for (const el of [...document.querySelectorAll("div, section, aside, dialog")]) {
267
+ const t = (el.innerText || el.textContent || "").trim();
268
+ if (t.length > 0 && t.length < 300 && privacy.test(t) && el.children.length < 12) {
269
+ el.remove();
270
+ }
271
+ }
272
+ })()`,
273
+ awaitPromise: true,
274
+ returnByValue: true,
275
+ });
276
+ await sleep(800);
277
+
278
+ const afterHref = (
279
+ await page("Runtime.evaluate", {
280
+ expression: "location.href",
281
+ returnByValue: true,
282
+ })
283
+ ).result.value;
284
+
285
+ if (afterHref !== beforeHref) {
286
+ console.error(`navigated away: ${afterHref}`);
287
+ drop();
288
+ process.exit(1);
289
+ }
290
+
291
+ await page(
292
+ "Runtime.evaluate",
293
+ {
294
+ expression: `(() => new Promise((done) => {
295
+ (async () => {
296
+ for (const img of document.images) {
297
+ if (img.loading === "lazy") img.loading = "eager";
298
+ }
299
+ const dwell = (ms) => new Promise((r) => setTimeout(r, ms));
300
+ const step = Math.max(480, Math.round(window.innerHeight * 0.65));
301
+ const limit = Math.min(
302
+ Math.max(document.documentElement.scrollHeight, document.body?.scrollHeight || 0),
303
+ 14000
304
+ );
305
+ let y = 0;
306
+ while (y < limit) {
307
+ y = Math.min(limit, y + step);
308
+ window.scrollTo(0, y);
309
+ await dwell(600);
310
+ }
311
+ await Promise.race([
312
+ Promise.all([...document.images].map((img) => img.decode().catch(() => {}))),
313
+ dwell(8000),
314
+ ]);
315
+ window.scrollTo(0, 0);
316
+ await dwell(700);
317
+ done();
318
+ })().catch(() => done());
319
+ }))()`,
320
+ awaitPromise: true,
321
+ returnByValue: true,
322
+ },
323
+ 90000,
324
+ );
325
+
326
+ await page("Runtime.evaluate", {
327
+ expression: `(() => {
328
+ const style = document.createElement("style");
329
+ style.textContent = \`
330
+ html, body { height: auto !important; max-height: none !important; overflow: visible !important; }
331
+ * { animation-play-state: paused !important; transition: none !important; scroll-behavior: auto !important; }
332
+ \`;
333
+ document.head.appendChild(style);
334
+ for (const el of document.querySelectorAll("*")) {
335
+ const pos = getComputedStyle(el).position;
336
+ if (pos === "fixed" || pos === "sticky") {
337
+ el.style.setProperty("position", "relative", "important");
338
+ el.style.setProperty("top", "auto", "important");
339
+ el.style.setProperty("bottom", "auto", "important");
340
+ }
341
+ }
342
+ })()`,
343
+ awaitPromise: true,
344
+ returnByValue: true,
345
+ });
346
+ await sleep(400);
347
+
348
+ // A redirect can land late (an app checks the session after it loads), so
349
+ // the address is checked last, right before the shot.
350
+ if (target === url) {
351
+ const landed = (await page("Runtime.evaluate", { expression: "location.href", returnByValue: true })).result.value;
352
+ const where = (href) => {
353
+ const u = new URL(href);
354
+ return `${u.origin}${u.pathname.replace(/\/$/, "")}`;
355
+ };
356
+ if (where(landed) !== where(url)) {
357
+ console.error(`landed on ${landed}, not ${url}.${/^https?:/.test(landed) ? " Behind a login? Pass --cookie." : " Check the address."}`);
358
+ if (strict) {
359
+ drop();
360
+ process.exit(1);
361
+ }
362
+ }
363
+ }
364
+
365
+ // --clip-selector takes the element's box in document coordinates, measured
366
+ // after the unstick pass so the numbers match what the capture sees.
367
+ let selected = null;
368
+ if (clipSelector) {
369
+ const { result } = await page("Runtime.evaluate", {
370
+ expression: `(() => {
371
+ const el = document.querySelector(${JSON.stringify(clipSelector)});
372
+ if (!el) return null;
373
+ const r = el.getBoundingClientRect();
374
+ return {
375
+ x: Math.max(0, Math.round(r.left + window.scrollX)),
376
+ y: Math.max(0, Math.round(r.top + window.scrollY)),
377
+ width: Math.round(r.width),
378
+ height: Math.round(r.height),
379
+ };
380
+ })()`,
381
+ returnByValue: true,
382
+ });
383
+ selected = result?.value || null;
384
+ if (!selected) {
385
+ console.error(`no element matches ${clipSelector}`);
386
+ drop();
387
+ process.exit(1);
388
+ }
389
+ if (selected.width < 1 || selected.height < 1) {
390
+ console.error(`${clipSelector} has no box (width ${selected.width}, height ${selected.height})`);
391
+ drop();
392
+ process.exit(1);
393
+ }
394
+ }
395
+
396
+ const metrics = await page("Page.getLayoutMetrics");
397
+ const size = metrics.cssContentSize || metrics.contentSize;
398
+ const fullWidth = Math.max(1, Math.ceil(size.width || width));
399
+ const fullHeight = Math.max(1, Math.min(Math.ceil(size.height || height), 14000));
400
+ const clipBox = clip || (selected ? { ...selected, scale: 1 } : null);
401
+ const shotClip = clipBox
402
+ ? {
403
+ x: Math.min(clipBox.x, fullWidth - 1),
404
+ y: Math.min(clipBox.y, fullHeight - 1),
405
+ width: Math.min(clipBox.width, fullWidth - Math.min(clipBox.x, fullWidth - 1)),
406
+ height: Math.min(clipBox.height, fullHeight - Math.min(clipBox.y, fullHeight - 1)),
407
+ scale: 1,
408
+ }
409
+ : { x: 0, y: 0, width: fullWidth, height: fullHeight, scale: 1 };
410
+
411
+ // The file is what its name says, so a reader that trusts the extension is right.
412
+ const format = /\.png$/i.test(out) ? "png" : /\.webp$/i.test(out) ? "webp" : "jpeg";
413
+ const { data } = await page(
414
+ "Page.captureScreenshot",
415
+ {
416
+ format,
417
+ ...(format === "png" ? {} : { quality: 70 }),
418
+ captureBeyondViewport: true,
419
+ clip: shotClip,
420
+ },
421
+ 60000,
422
+ );
423
+
424
+ mkdirSync(dirname(out), { recursive: true });
425
+ writeFileSync(out, Buffer.from(data, "base64"));
426
+ console.log(out);
427
+
428
+ if (reviewOut) {
429
+ // Side-by-side columns ~2800 px tall so a tall capture stays readable.
430
+ // Real capture stays the single tall file; review is scratch only.
431
+ const reviewHtml = `<!doctype html><meta charset=utf-8>
432
+ <canvas id=c></canvas>
433
+ <script>
434
+ const src = "data:image/${format};base64,${data}";
435
+ const img = new Image();
436
+ img.onload = () => {
437
+ const colH = 2800;
438
+ const gap = 20;
439
+ const cols = Math.max(1, Math.ceil(img.height / colH));
440
+ const c = document.getElementById("c");
441
+ c.width = cols * img.width + (cols - 1) * gap;
442
+ c.height = Math.min(colH, img.height);
443
+ const ctx = c.getContext("2d");
444
+ ctx.fillStyle = "#111";
445
+ ctx.fillRect(0, 0, c.width, c.height);
446
+ for (let i = 0; i < cols; i++) {
447
+ const sy = i * colH;
448
+ const sh = Math.min(colH, img.height - sy);
449
+ ctx.drawImage(img, 0, sy, img.width, sh, i * (img.width + gap), 0, img.width, sh);
450
+ }
451
+ document.title = "ready";
452
+ };
453
+ img.src = src;
454
+ </script>`;
455
+ const reviewPage = join(dir, "review.html");
456
+ writeFileSync(reviewPage, reviewHtml);
457
+ await page("Page.navigate", { url: `file://${reviewPage}` }, 20000);
458
+ await sleep(400);
459
+ for (let i = 0; i < 40; i++) {
460
+ const title = (
461
+ await page("Runtime.evaluate", { expression: "document.title", returnByValue: true })
462
+ ).result.value;
463
+ if (title === "ready") break;
464
+ await sleep(100);
465
+ }
466
+ const { result: sizeResult } = await page("Runtime.evaluate", {
467
+ expression: `(() => {
468
+ const c = document.getElementById("c");
469
+ return { w: c.width, h: c.height };
470
+ })()`,
471
+ returnByValue: true,
472
+ });
473
+ const { data: reviewData } = await page(
474
+ "Page.captureScreenshot",
475
+ {
476
+ format: /\.png$/i.test(reviewOut) ? "png" : "jpeg",
477
+ quality: 75,
478
+ clip: { x: 0, y: 0, width: sizeResult.value.w, height: sizeResult.value.h, scale: 1 },
479
+ captureBeyondViewport: true,
480
+ },
481
+ 60000,
482
+ );
483
+ mkdirSync(dirname(reviewOut), { recursive: true });
484
+ writeFileSync(reviewOut, Buffer.from(reviewData, "base64"));
485
+ console.log(reviewOut);
486
+ }
487
+
488
+ drop();
489
+ process.exit(0);
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  // Build labelled contact sheets from a TSV of label\timageURL.
3
- // Writes JPEG grids (~36 per sheet) into an output directory (scratch, not .design/).
3
+ // Writes JPEG grids (~36 per sheet) into an output directory (scratch, not design-exploration/).
4
4
  // Viewing listing thumbnails is allowed; this is not a capture.
5
5
  //
6
6
  // node contact-sheet.mjs candidates.tsv --out /tmp/hunt-sheets
@@ -1,14 +1,21 @@
1
1
  #!/usr/bin/env node
2
2
  // List Dribbble search/popular cards from a listing URL.
3
- // Headless Chrome; prints TSV: id-slug\tlikes\tviews\timageURL\ttitle
3
+ // Headless Chrome; prints TSV: id-slug\tlikes\tviews\tdesigner\timageURL\ttitle
4
4
  // Counts come from the card's own stat elements. A column it cannot read
5
5
  // stays empty. It never guesses a count from the title.
6
6
  //
7
+ // Dribbble's "popular" order mixes likes with recency, so page order is not
8
+ // quality. Rows come out sorted by likes, most first, and a card under
9
+ // --min-likes (default 100) is dropped. A card whose likes cannot be read
10
+ // is kept, last.
11
+ //
7
12
  // Off-topic cards (merch, resumes, worksheets, posters) are dropped by slug
8
13
  // and title before anything is fetched, and the noise rate goes to stderr.
9
14
  //
10
15
  // node dribbble-cards.mjs "https://dribbble.com/search/shots/popular/product-design?q=writing+app&timeframe=year" --scrolls 4
11
16
  // node dribbble-cards.mjs "<url>" --drop "mood,habit" --keep "font,illustration"
17
+ // node dribbble-cards.mjs "<url>" --min-likes 300
18
+ // node dribbble-cards.mjs "<url>" --picker >> candidates.tsv # rows for picker.mjs
12
19
  import { spawn } from "node:child_process";
13
20
  import { existsSync, mkdtempSync, rmSync } from "node:fs";
14
21
  import { tmpdir } from "node:os";
@@ -31,6 +38,8 @@ const has = (name) => {
31
38
  const url = args[0];
32
39
  const scrolls = Math.max(0, Number(flag("scrolls", "3")) || 3);
33
40
  const noFilter = has("no-filter");
41
+ const forPicker = has("picker");
42
+ const minLikes = Math.max(0, Number(flag("min-likes", "100")) || 0);
34
43
  const words = (s) =>
35
44
  String(s || "")
36
45
  .toLowerCase()
@@ -56,7 +65,7 @@ const keep = words(flag("keep", ""));
56
65
  const dropWords = [...OFF_TOPIC.filter((w) => !keep.includes(w)), ...words(flag("drop", ""))];
57
66
  if (!url || !/^https?:\/\/(www\.)?dribbble\.com\//i.test(url)) {
58
67
  console.error(
59
- 'usage: node dribbble-cards.mjs "https://dribbble.com/search/..." [--scrolls 4] [--drop "a,b"] [--keep "a,b"] [--no-filter]',
68
+ 'usage: node dribbble-cards.mjs "https://dribbble.com/search/..." [--scrolls 4] [--min-likes 100] [--drop "a,b"] [--keep "a,b"] [--no-filter] [--picker]',
60
69
  );
61
70
  process.exit(2);
62
71
  }
@@ -68,6 +77,14 @@ function offTopic(text) {
68
77
  return dropWords.find((word) => hay.includes(` ${word.replace(/[^a-z0-9]+/g, " ")} `)) || "";
69
78
  }
70
79
 
80
+ // "15.7k" -> 15700. An unreadable count is NaN, never 0.
81
+ function count(text) {
82
+ const m = String(text || "").replace(/,/g, "").match(/^([\d.]+)([kKmM]?)$/);
83
+ if (!m) return NaN;
84
+ const n = Number(m[1]) * ({ k: 1e3, m: 1e6 }[m[2].toLowerCase()] || 1);
85
+ return Number.isFinite(n) ? n : NaN;
86
+ }
87
+
71
88
  function findChrome() {
72
89
  const env = process.env.CHROME_PATH;
73
90
  if (env && existsSync(env)) return env;
@@ -264,8 +281,11 @@ const { result } = await page("Runtime.evaluate", {
264
281
  likes = counts[0] || "";
265
282
  views = counts[1] || "";
266
283
  }
284
+ // The profile handle, from the card's own designer link.
285
+ const who = li.querySelector('.user-information a[href^="/"]');
286
+ const designer = who ? (who.getAttribute("href") || "").replace(/^\\/|[?#].*$/g, "") : "";
267
287
  const title = (img.getAttribute("alt") || a.getAttribute("title") || idSlug).replace(/\\t/g, " ").trim();
268
- rows.push([idSlug, likes, views, imageURL, title].join("\\t"));
288
+ rows.push([idSlug, likes, views, designer, imageURL, title].join("\\t"));
269
289
  }
270
290
  return rows.join("\\n");
271
291
  })()`,
@@ -286,7 +306,7 @@ const reasons = new Map();
286
306
  const kept = noFilter
287
307
  ? all
288
308
  : all.filter((row) => {
289
- const [idSlug, , , , title = ""] = row.split("\t");
309
+ const [idSlug, , , , , title = ""] = row.split("\t");
290
310
  const word = offTopic(`${idSlug} ${title}`);
291
311
  if (!word) return true;
292
312
  reasons.set(word, (reasons.get(word) ?? 0) + 1);
@@ -310,6 +330,27 @@ if (!kept.length) {
310
330
  drop();
311
331
  process.exit(1);
312
332
  }
313
- console.log(kept.join("\n"));
333
+ // Likes are the signal people valued a shot. Sort by them, and drop the
334
+ // ones under the floor. An unreadable count is kept, last, so a markup
335
+ // change shows as empty columns instead of an empty list.
336
+ const likesOf = (row) => count(row.split("\t")[1]);
337
+ const strong = kept.filter((row) => !(likesOf(row) < minLikes));
338
+ const weak = kept.length - strong.length;
339
+ if (weak > 0) {
340
+ console.error(`${weak} of ${kept.length} under ${minLikes} likes, dropped (lower it with --min-likes)`);
341
+ }
342
+ if (!strong.length) {
343
+ console.error("every card was under the likes floor — try a broader form or timeframe before lowering it");
344
+ drop();
345
+ process.exit(1);
346
+ }
347
+ strong.sort((a, b) => (likesOf(b) || -1) - (likesOf(a) || -1));
348
+ // --picker prints picker.mjs rows: title, thumbnail, shot page, source, meta.
349
+ const asPicker = (row) => {
350
+ const [idSlug, likes, , designer, imageURL, title] = row.split("\t");
351
+ const meta = [designer, likes && `${likes} likes`].filter(Boolean).join(" · ");
352
+ return [title, `${imageURL}?resize=400x300`, `https://dribbble.com/shots/${idSlug}`, "dribbble", meta].join("\t");
353
+ };
354
+ console.log((forPicker ? strong.map(asPicker) : strong).join("\n"));
314
355
  drop();
315
356
  process.exit(0);