captchakraken 5.0.0-beta.49 → 5.0.0-beta.51

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.
@@ -14,6 +14,7 @@ export interface PlaywrightElementHandle {
14
14
  timeout?: number;
15
15
  animations?: 'disabled' | 'allow';
16
16
  style?: string;
17
+ scale?: 'css' | 'device';
17
18
  }): Promise<Buffer>;
18
19
  contentFrame(): Promise<PlaywrightFrame | null>;
19
20
  /** The frame the element lives in. Optional: an adapter without it never moves the solve into a nested board frame. */
@@ -66,6 +67,7 @@ export interface PlaywrightResponse {
66
67
  request?(): {
67
68
  resourceType?(): string;
68
69
  };
70
+ headers?(): Record<string, string>;
69
71
  }
70
72
  /**
71
73
  * Structural on purpose: the package depends on no browser library, and the version skew between
@@ -105,6 +107,7 @@ export interface PlaywrightPage extends PlaywrightScope {
105
107
  timeout?: number;
106
108
  animations?: 'disabled' | 'allow';
107
109
  style?: string;
110
+ scale?: 'css' | 'device';
108
111
  }): Promise<Buffer>;
109
112
  /** Optional: the mouse humanizer asks the window for its size when `viewportSize()` is null (camoufox). */
110
113
  evaluate?<R>(pageFunction: () => R): Promise<R>;
@@ -19,7 +19,7 @@ export interface VendorSelectors {
19
19
  * An in-page checkbox that names one is a button with no tick box to find, and is clicked where it is.
20
20
  */
21
21
  readonly box?: readonly string[];
22
- /** On the host page: the vendor painted its success state. Visibility is part of the test (see TRIBAL_KNOWLEDGE.md). */
22
+ /** On the host page, or inside the vendor's challenge frame: the vendor painted its success state. Visibility is part of the test (see TRIBAL_KNOWLEDGE.md). */
23
23
  readonly accepted?: string;
24
24
  /** Inside the challenge frame: a new round has painted, with text. */
25
25
  readonly fresh?: string;
@@ -68,6 +68,12 @@ export interface VendorSelectors {
68
68
  * answer's `to` is not a release, and the hold lasts until the widget says it is done.
69
69
  */
70
70
  readonly holdCompletes?: boolean;
71
+ /**
72
+ * Every board this vendor deals is a still: none has ever been seen to animate, live or in training. The driver asks
73
+ * such a board at once instead of first filming it for the animation floor (4s a board), and a still answer that
74
+ * fails still earns the recording on the next round. Unset, a vendor is filmed before it is asked.
75
+ */
76
+ readonly stillsOnly?: boolean;
71
77
  }
72
78
  /** A selector config file's shape: the repository's `captchakraken.config.json`, or any part of it. */
73
79
  export interface SelectorConfigFile {
package/dist/selectors.js CHANGED
@@ -24,9 +24,9 @@ class SelectorConfigError extends Error {
24
24
  exports.SelectorConfigError = SelectorConfigError;
25
25
  const GENERIC = ['submit_text', 'text_input', 'slider_handle', 'piece', 'feedback'];
26
26
  // The file is spelled as the Python port's fields; these three are camelCase here.
27
- const CAMEL = { text_input: 'textInput', slider_handle: 'sliderHandle', hold_completes: 'holdCompletes' };
27
+ const CAMEL = { text_input: 'textInput', slider_handle: 'sliderHandle', hold_completes: 'holdCompletes', stills_only: 'stillsOnly' };
28
28
  const FIELDS = ['hosts', 'challenge', 'checkbox', 'enclave', 'widget', 'response', 'checked', 'box', 'accepted', 'fresh',
29
- 'images', 'tiles', 'submit', 'banners', 'blocked', 'passive', 'text_input', 'slider_handle', 'bar', 'board', 'piece', 'band', 'refresh', 'hold_completes'];
29
+ 'images', 'tiles', 'submit', 'banners', 'blocked', 'passive', 'text_input', 'slider_handle', 'bar', 'board', 'piece', 'band', 'refresh', 'hold_completes', 'stills_only'];
30
30
  const ONE = new Set(['response', 'checked', 'accepted', 'fresh']);
31
31
  const BANNERS = new Set(Object.values(kinds_1.RecaptchaBanner));
32
32
  const VENDOR_VALUES = new Set(Object.values(kinds_1.Vendor));
@@ -54,7 +54,7 @@ function entry(where, raw, hostsRequired = true) {
54
54
  if (value !== null)
55
55
  out[name] = value;
56
56
  }
57
- else if (key === 'hold_completes') {
57
+ else if (key === 'hold_completes' || key === 'stills_only') {
58
58
  if (typeof value !== 'boolean')
59
59
  throw new SelectorConfigError(`${at}: must be true or false`);
60
60
  if (value)
package/dist/solver.d.ts CHANGED
@@ -156,6 +156,7 @@ export declare class CaptchaKrakenSolver {
156
156
  * repaints nothing, and measured twice as fast. `disabled` freezes CSS animation, which once sliced GeeTest svg to
157
157
  * a static clip; callers filming motion pass `allow`.
158
158
  */
159
+ /** `scale: 'css'` is one pixel per CSS pixel: the slide loop's, since a phone's device-pixel frame is ~7x the pixels to track. */
159
160
  private shot;
160
161
  private rectOf;
161
162
  /** Where the element sits in the viewport, scrolled in when it is merely off screen; null when it cannot fit. */
package/dist/solver.js CHANGED
@@ -440,17 +440,20 @@ class CaptchaKrakenSolver {
440
440
  * repaints nothing, and measured twice as fast. `disabled` freezes CSS animation, which once sliced GeeTest svg to
441
441
  * a static clip; callers filming motion pass `allow`.
442
442
  */
443
- async shot(el, p, timeout = 2500, animations = 'disabled', style) {
443
+ /** `scale: 'css'` is one pixel per CSS pixel: the slide loop's, since a phone's device-pixel frame is ~7x the pixels to track. */
444
+ async shot(el, p, timeout = 2500, animations = 'disabled', style, scale = 'device') {
444
445
  const page = this.page;
445
446
  const view = await viewportOf(page);
446
447
  const rect = (await layoutIsTheViewport(page, view)) ? await this.rectInView(el, view) : null;
448
+ // Device scale is Playwright's default, so only the slide loop's css changes the call.
449
+ const css = scale === 'css' ? { scale } : {};
447
450
  if (!rect) {
448
451
  // Bigger than the viewport, or a zoomed-out mobile layout: no viewport capture holds it in its own
449
452
  // coordinates, so the element photographs itself.
450
- await el.screenshot({ path: p, timeout, animations, style });
453
+ await el.screenshot({ path: p, timeout, animations, style, ...css });
451
454
  return;
452
455
  }
453
- fs.writeFileSync(p, (0, png_1.cropPng)(await page.screenshot({ timeout, animations, style }), rect, view.width));
456
+ fs.writeFileSync(p, (0, png_1.cropPng)(await page.screenshot({ timeout, animations, style, ...css }), rect, view.width));
454
457
  }
455
458
  async rectOf(el) {
456
459
  const box = await el.boundingBox();
@@ -883,14 +886,23 @@ class CaptchaKrakenSolver {
883
886
  const filmable = puzzleSource !== kinds_1.Vendor.RECAPTCHA && !textMode;
884
887
  if (filmable && !this.knownAnimated)
885
888
  await this.stepOffTheBoard(page, captchaElement);
889
+ // What the vendor's network said about this board (verdicts.ts MOTION_SIGNALS); null films it to find out.
890
+ const dealtMotion = filmable && this.verdicts ? await this.verdicts.boardMotion(puzzleSource) : null;
886
891
  let isAnimated = false;
887
892
  if (filmable && cfg.videoSolveEnabled === false) {
888
- if (await this.ph(kinds_1.Phase.SETTLE, () => this.waitForElementSettled(captchaElement)) === kinds_1.SettleVerdict.ANIMATED) {
893
+ if (dealtMotion === true
894
+ || await this.ph(kinds_1.Phase.SETTLE, () => this.waitForElementSettled(captchaElement)) === kinds_1.SettleVerdict.ANIMATED) {
889
895
  const e = new Error('ANIMATED_CHALLENGE: the challenge never settles and videoSolveEnabled is off.');
890
896
  e.animated = true;
891
897
  throw e;
892
898
  }
893
899
  }
900
+ else if (filmable && dealtMotion === true && !this.knownAnimated) {
901
+ // The vendor dealt this board as a video: waiting for it to settle would only wait out a cycle.
902
+ console.log('[animated] the vendor dealt this board as a video — filming it');
903
+ await this.releasePendingBurst();
904
+ isAnimated = this.knownAnimated = true;
905
+ }
894
906
  else if (filmable) {
895
907
  isAnimated = await this.classifyByRecording(captchaElement) === kinds_1.SettleVerdict.ANIMATED;
896
908
  }
@@ -1035,7 +1047,7 @@ class CaptchaKrakenSolver {
1035
1047
  }
1036
1048
  }
1037
1049
  }
1038
- if (!response && this.shouldSpeculate(puzzleSource, textMode)) {
1050
+ if (!response && this.shouldSpeculate(puzzleSource, textMode, dealtMotion)) {
1039
1051
  // Ask the still and film at once. No idle wander: a moving cursor reads as new screens.
1040
1052
  const rec = this.pendingBurst ?? this.startKeyframeBurst(captchaElement);
1041
1053
  this.pendingBurst = null;
@@ -1345,6 +1357,9 @@ class CaptchaKrakenSolver {
1345
1357
  async isCaptchaSolved(page) {
1346
1358
  try {
1347
1359
  const checkboxes = this.sel.widgetProbes.filter((p) => p.role === kinds_1.FrameRole.CHECKBOX && this.sel.selectors[p.vendor].checked);
1360
+ // A vendor that draws its whole challenge in one frame (DataDome) paints its pass in there, then reloads the
1361
+ // page about a second later: unread, the next round filmed the closing frame.
1362
+ const challenges = this.sel.widgetProbes.filter((p) => p.role === kinds_1.FrameRole.CHALLENGE && this.sel.selectors[p.vendor].accepted);
1348
1363
  const scopes = await hostScopes(page, this.sel.enclave);
1349
1364
  const signals = await Promise.all([
1350
1365
  ...this.sel.response.map((s) => this.hasValue(scopes, s)),
@@ -1353,6 +1368,11 @@ class CaptchaKrakenSolver {
1353
1368
  const [at] = await visibleIn(scopes, [p.selector]);
1354
1369
  return !!at && this.checkedIn(at, this.sel.selectors[p.vendor].checked);
1355
1370
  }),
1371
+ ...challenges.map(async (p) => {
1372
+ const [at] = await visibleIn(scopes, [p.selector]);
1373
+ const frame = at && await frameOf(at);
1374
+ return !!frame && (await visible(frame, [this.sel.selectors[p.vendor].accepted])).length > 0;
1375
+ }),
1356
1376
  ]);
1357
1377
  return signals.some(Boolean);
1358
1378
  }
@@ -2589,7 +2609,7 @@ class CaptchaKrakenSolver {
2589
2609
  if (rec)
2590
2610
  await rec.abandon();
2591
2611
  }
2592
- shouldSpeculate(puzzleSource, textMode) {
2612
+ shouldSpeculate(puzzleSource, textMode, dealtMotion = null) {
2593
2613
  if (this.config.videoSolveEnabled === false)
2594
2614
  return false;
2595
2615
  if (this.config.speculativeBurstEnabled === false)
@@ -2601,6 +2621,13 @@ class CaptchaKrakenSolver {
2601
2621
  return false;
2602
2622
  if (textMode)
2603
2623
  return false;
2624
+ // A vendor whose boards are all stills is asked at once: filming it cost every slider and hold 4s of a 15s
2625
+ // budget (measured on the 5.0 Tier 3 run), and a still answer that fails earns the film next round.
2626
+ if (this.sel.selectors[puzzleSource]?.stillsOnly)
2627
+ return false;
2628
+ // So is a board its vendor dealt as a still file; the burst stays for every board no network has described.
2629
+ if (dealtMotion === false)
2630
+ return false;
2604
2631
  return true;
2605
2632
  }
2606
2633
  /** One second look per solve: a repeated answer arms it, and the recording it takes spends it. */
@@ -3303,11 +3330,11 @@ class CaptchaKrakenSolver {
3303
3330
  await this.human.press(page);
3304
3331
  await this.human.pause(kinds_1.PauseKind.GRAB);
3305
3332
  const rest = bands.length ? await this.readBands(bands) : null;
3306
- await this.shot(element, first, timeout);
3333
+ await this.shot(element, first, timeout, 'disabled', undefined, 'css');
3307
3334
  const k = this.shotScale(first, w);
3308
3335
  await this.performSmoothMove(page, press[0] + probe, press[1]);
3309
3336
  await this.human.pause(kinds_1.PauseKind.PROBE);
3310
- await this.shot(element, probed, timeout);
3337
+ await this.shot(element, probed, timeout, 'disabled', undefined, 'css');
3311
3338
  const ask = {
3312
3339
  first, probe: probed, probe_s: probe * k, goal: [goal[0] * k, goal[1] * k], seed: seed && [seed[0] * k, seed[1] * k],
3313
3340
  handle: [handle[0] * k, handle[1] * k], bounds: [-handle[0] * k, (w - handle[0]) * k], tol: SLIDE_TOLERANCE_PX * k,
@@ -3346,7 +3373,7 @@ class CaptchaKrakenSolver {
3346
3373
  await this.human.pause(kinds_1.PauseKind.PROBE);
3347
3374
  if (rolling)
3348
3375
  continue;
3349
- await this.shot(element, current, timeout);
3376
+ await this.shot(element, current, timeout, 'disabled', undefined, 'css');
3350
3377
  look = current;
3351
3378
  }
3352
3379
  await this.human.pause(kinds_1.PauseKind.SETTLE);
@@ -24,6 +24,30 @@ export declare function endpointFor(url: string): {
24
24
  endpoint: VerdictEndpoint;
25
25
  } | null;
26
26
  export declare function readVerdict(url: string, status: number, body: string): RoundVerdict | null;
27
+ export interface MotionSignal {
28
+ /** A URL substring naming the response that carries the board, or names its kind. */
29
+ marker: string;
30
+ read: (contentType: string, body: string) => boolean | null;
31
+ needsBody: boolean;
32
+ }
33
+ export declare const MOTION_SIGNALS: Partial<Record<Vendor, readonly MotionSignal[]>>;
34
+ export declare const TIMELINE_JS = "() => {\n const all = performance.getEntriesByType('resource');\n return {full: all.length >= 250, entries: all.map(e => [e.initiatorType, e.name])};\n}";
35
+ export interface Timeline {
36
+ full?: boolean;
37
+ entries?: [string, string][];
38
+ }
39
+ interface TimelineBoard {
40
+ deal: string;
41
+ board: string;
42
+ read: (initiator: string, url: string) => boolean | null;
43
+ }
44
+ export declare const TIMELINE_BOARDS: Partial<Record<Vendor, TimelineBoard>>;
45
+ /** What one frame's resource timeline says about the vendor's latest board, or null. */
46
+ export declare function motionFromTimeline(vendor: Vendor, timeline: Timeline | null | undefined): boolean | null;
47
+ export declare function motionSignalFor(url: string): {
48
+ vendor: Vendor;
49
+ signal: MotionSignal;
50
+ } | null;
27
51
  /**
28
52
  * Every verdict the page's network carries while a solve runs.
29
53
  *
@@ -39,6 +63,12 @@ export declare class VerdictLog {
39
63
  private read;
40
64
  private pending;
41
65
  private readonly listener;
66
+ /** What each vendor's network said about its current board: true moves, false is still. */
67
+ private readonly motion;
68
+ private readonly deals;
69
+ private noteMotion;
70
+ /** Whether the vendor dealt its current board as a moving one; null when its network has not said. */
71
+ boardMotion(vendor: Vendor): Promise<boolean | null>;
42
72
  constructor(page: PlaywrightPage);
43
73
  /** The verdicts that arrived since the last call, once every body already on the wire has been read. */
44
74
  fresh(): Promise<RoundVerdict[]>;
@@ -46,3 +76,4 @@ export declare class VerdictLog {
46
76
  decisive(): Verdict | null;
47
77
  close(): Promise<void>;
48
78
  }
79
+ export {};
package/dist/verdicts.js CHANGED
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VerdictLog = exports.VERDICT_ENDPOINTS = void 0;
3
+ exports.VerdictLog = exports.TIMELINE_BOARDS = exports.TIMELINE_JS = exports.MOTION_SIGNALS = exports.VERDICT_ENDPOINTS = void 0;
4
4
  exports.endpointFor = endpointFor;
5
5
  exports.readVerdict = readVerdict;
6
+ exports.motionFromTimeline = motionFromTimeline;
7
+ exports.motionSignalFor = motionSignalFor;
6
8
  /**
7
9
  * The vendor's own answer to each submitted round, read off the wire. Mirrors python/src/captchakraken/verdicts.py.
8
10
  *
@@ -113,6 +115,89 @@ function readVerdict(url, status, body) {
113
115
  const verdict = status >= 200 && status < 300 ? found.endpoint.read(body) : null;
114
116
  return verdict ? { vendor: found.vendor, verdict } : null;
115
117
  }
118
+ // ── whether a board moves, read off the file it is dealt as ──────────────────
119
+ // Measured 2026-11-14 on the live demos. hCaptcha (46 deals over three sitekeys) loads each board from
120
+ // imgs*.hcaptcha.com/tip/: image/jpeg for every still deal, video/webm for every animated one. GeeTest v4's /load names
121
+ // its challenge in plain JSONP, and only the two svg types moved (22 deals over seven demo pages). A vendor, file or
122
+ // type not listed here gives no hint, and the driver films the board to find out, as it always has.
123
+ const GEETEST_MOVING = new Set(['svg_icon', 'svg_seed']);
124
+ const GEETEST_STILL = new Set(['slide', 'icon', 'nine', 'match', 'winlinze']);
125
+ const mediaMoves = (contentType) => {
126
+ // A GIF may move, so it says nothing either way; every still hCaptcha board measured was a jpeg or a png.
127
+ const type = contentType.split(';', 1)[0].trim().toLowerCase();
128
+ if (type === 'image/gif')
129
+ return null;
130
+ const kind = type.split('/', 1)[0];
131
+ return kind === 'video' ? true : kind === 'image' ? false : null;
132
+ };
133
+ // GenerateCaptcha names the board's file in HtmlFormate; every one measured (4 deals) was a GIF that moved.
134
+ const cybersiaraBoardMoves = (_contentType, body) => {
135
+ const board = parse(body)?.HtmlFormate;
136
+ return typeof board === 'string' && board.toLowerCase().split('?', 1)[0].endsWith('.gif') ? true : null;
137
+ };
138
+ const geetestTypeMoves = (_contentType, body) => {
139
+ const start = body.indexOf('(');
140
+ const end = body.lastIndexOf(')');
141
+ const data = (start >= 0 && start < end ? parse(body.slice(start + 1, end)) : null);
142
+ const kind = data?.data?.captcha_type;
143
+ if (typeof kind !== 'string')
144
+ return null;
145
+ return GEETEST_MOVING.has(kind) ? true : GEETEST_STILL.has(kind) ? false : null;
146
+ };
147
+ exports.MOTION_SIGNALS = {
148
+ [kinds_1.Vendor.HCAPTCHA]: [{ marker: 'hcaptcha.com/tip/', read: mediaMoves, needsBody: false }],
149
+ [kinds_1.Vendor.GEETEST]: [{ marker: 'geetest.com/load', read: geetestTypeMoves, needsBody: true }],
150
+ [kinds_1.Vendor.CYBERSIARA]: [{ marker: 'mycybersiara.com/api/GenerateCaptcha', read: cybersiaraBoardMoves, needsBody: true }],
151
+ };
152
+ // ── the same, read back from a frame's performance timeline ──────────────────
153
+ // The listener hears only what loads after solve() starts. A widget the caller opened first, or a board the browser
154
+ // served from its cache, was dealt before then, and each frame's resource timeline still lists what it loaded and what
155
+ // loaded it. Only entries after the vendor's latest deal count, and a full buffer (where new entries are dropped and the
156
+ // latest deal may be missing) says nothing. Measured 2026-11-14: GeeTest's board files sit under
157
+ // static.geetest.com/captcha_v4/policy/<id>/<captcha_type>/, hCaptcha's under /tip/ loaded by an img, CyberSiara's as
158
+ // a GIF under embed.mycybersiara.com/CyberSiara/.
159
+ exports.TIMELINE_JS = `() => {
160
+ const all = performance.getEntriesByType('resource');
161
+ return {full: all.length >= 250, entries: all.map(e => [e.initiatorType, e.name])};
162
+ }`;
163
+ const hcaptchaTipMoves = (initiator) => ['video', 'audio', 'source'].includes(initiator) ? true : initiator === 'img' ? false : null;
164
+ const geetestPathMoves = (_initiator, url) => {
165
+ const kind = url.split('captcha_v4/policy/').slice(-1)[0].split('/')[1];
166
+ return kind === undefined ? null : GEETEST_MOVING.has(kind) ? true : GEETEST_STILL.has(kind) ? false : null;
167
+ };
168
+ const cybersiaraFileMoves = (_initiator, url) => url.toLowerCase().split('?', 1)[0].endsWith('.gif') ? true : null;
169
+ exports.TIMELINE_BOARDS = {
170
+ [kinds_1.Vendor.HCAPTCHA]: { deal: 'hcaptcha.com/getcaptcha/', board: 'hcaptcha.com/tip/', read: hcaptchaTipMoves },
171
+ [kinds_1.Vendor.GEETEST]: { deal: 'geetest.com/load', board: 'static.geetest.com/captcha_v4/policy/', read: geetestPathMoves },
172
+ [kinds_1.Vendor.CYBERSIARA]: {
173
+ deal: 'mycybersiara.com/api/GenerateCaptcha', board: 'mycybersiara.com/CyberSiara/', read: cybersiaraFileMoves,
174
+ },
175
+ };
176
+ const combine = (reads) => reads.includes(true) ? true : reads.includes(false) ? false : null;
177
+ /** What one frame's resource timeline says about the vendor's latest board, or null. */
178
+ function motionFromTimeline(vendor, timeline) {
179
+ const spec = exports.TIMELINE_BOARDS[vendor];
180
+ if (!spec || !timeline || timeline.full)
181
+ return null;
182
+ const entries = (timeline.entries ?? []).filter((e) => Array.isArray(e) && e.length === 2);
183
+ let lastDeal = -1;
184
+ entries.forEach(([, url], i) => { if (String(url).includes(spec.deal))
185
+ lastDeal = i; });
186
+ if (lastDeal < 0)
187
+ return null;
188
+ return combine(entries.slice(lastDeal + 1).filter(([, url]) => String(url).includes(spec.board))
189
+ .map(([kind, url]) => spec.read(String(kind), String(url))));
190
+ }
191
+ function motionSignalFor(url) {
192
+ return Object.entries(exports.MOTION_SIGNALS)
193
+ .flatMap(([vendor, signals]) => signals.map((signal) => ({ vendor, signal })))
194
+ .find(({ signal }) => url.includes(signal.marker)) ?? null;
195
+ }
196
+ /** The vendor whose deal endpoint this is: what it said about the last board no longer holds. */
197
+ function dealsABoard(url) {
198
+ const found = endpointFor(url);
199
+ return found && found.endpoint.read === urlOnly ? found.vendor : null;
200
+ }
116
201
  const SCRIPTED_REQUESTS = new Set(['xhr', 'fetch', 'script']);
117
202
  /**
118
203
  * Every verdict the page's network carries while a solve runs.
@@ -121,6 +206,34 @@ const SCRIPTED_REQUESTS = new Set(['xhr', 'fetch', 'script']);
121
206
  * records nothing, and the driver then judges every round by the DOM, as it always has.
122
207
  */
123
208
  class VerdictLog {
209
+ noteMotion(vendor, moves) {
210
+ // One moving file makes the board a moving one: a board may also load a still example.
211
+ if (moves !== null && !this.motion.get(vendor))
212
+ this.motion.set(vendor, moves);
213
+ }
214
+ /** Whether the vendor dealt its current board as a moving one; null when its network has not said. */
215
+ async boardMotion(vendor) {
216
+ await Promise.all([...this.pending]);
217
+ const heard = this.motion.get(vendor);
218
+ if (heard !== undefined || !exports.TIMELINE_BOARDS[vendor])
219
+ return heard ?? null;
220
+ let frames = [];
221
+ try {
222
+ frames = this.page.frames?.() ?? [];
223
+ }
224
+ catch {
225
+ return null;
226
+ }
227
+ const reads = await Promise.all(frames.map(async (frame) => {
228
+ try {
229
+ return motionFromTimeline(vendor, (await frame.evaluate?.(exports.TIMELINE_JS)));
230
+ }
231
+ catch {
232
+ return null;
233
+ }
234
+ }));
235
+ return combine(reads);
236
+ }
124
237
  constructor(page) {
125
238
  this.page = page;
126
239
  this.verdicts = [];
@@ -133,15 +246,42 @@ class VerdictLog {
133
246
  const status = response.status();
134
247
  if (SCRIPTED_REQUESTS.has(response.request?.().resourceType?.() ?? ''))
135
248
  this.exchanges++;
136
- if (!endpointFor(url))
249
+ const dealt = dealsABoard(url);
250
+ // At once, not when the body lands: the new board's own file can arrive first.
251
+ if (dealt) {
252
+ this.motion.delete(dealt);
253
+ this.deals.set(dealt, (this.deals.get(dealt) ?? 0) + 1);
254
+ }
255
+ const found = motionSignalFor(url);
256
+ const judged = endpointFor(url) !== null;
257
+ if (!judged && !found)
258
+ return;
259
+ if (found && status >= 200 && status < 300 && !found.signal.needsBody) {
260
+ let contentType = '';
261
+ try {
262
+ contentType = response.headers?.()['content-type'] ?? '';
263
+ }
264
+ catch { /* no header, no hint */ }
265
+ this.noteMotion(found.vendor, found.signal.read(contentType, ''));
266
+ }
267
+ const needsBody = judged || (found?.signal.needsBody ?? false);
268
+ // A body read for an earlier deal must not describe a board that has since been replaced.
269
+ const deal = found ? this.deals.get(found.vendor) ?? 0 : 0;
270
+ if (!needsBody)
137
271
  return;
138
272
  const body = status === TOO_MANY_REQUESTS ? Promise.resolve('') : response.text();
139
273
  this.pending.push(body.then((text) => {
274
+ if (found?.signal.needsBody && status >= 200 && status < 300 && (this.deals.get(found.vendor) ?? 0) === deal) {
275
+ this.noteMotion(found.vendor, found.signal.read('', text));
276
+ }
140
277
  const verdict = readVerdict(url, status, text);
141
278
  if (verdict)
142
279
  this.verdicts.push(verdict);
143
280
  }).catch(() => { }));
144
281
  };
282
+ /** What each vendor's network said about its current board: true moves, false is still. */
283
+ this.motion = new Map();
284
+ this.deals = new Map();
145
285
  this.listening = typeof page.on === 'function';
146
286
  page.on?.('response', this.listener);
147
287
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "captchakraken",
3
- "version": "5.0.0-beta.49",
3
+ "version": "5.0.0-beta.51",
4
4
  "description": "Captcha solver for Playwright and Puppeteer. Finds the captcha, reads it with the v2 pointer model, and clicks, drags, slides or types through to a token — reCAPTCHA, GeeTest, NetEase Yidun, Tencent, Lemin, Prosopo, Turnstile and distorted text. Hosted API or self-hosted.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "captchakraken"
7
- version = "5.0.0b49"
7
+ version = "5.0.0b51"
8
8
  description = "Captcha-solving engine and CLI: a v2 pointer model for image grids, click and drag puzzles, sliders, distorted text and animated challenges. Hosted API or self-hosted on vLLM."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -100,4 +100,4 @@ __all__ = [
100
100
  "PauseKind",
101
101
  ]
102
102
 
103
- __version__ = "5.0.0b49"
103
+ __version__ = "5.0.0b51"
@@ -19,7 +19,8 @@
19
19
  "the vendor's code on the wire; every other field is a list of CSS (or",
20
20
  "Playwright `xpath=`) selectors, except `response`, `checked`, `accepted` and",
21
21
  "`fresh` (one selector each), `banners` ([selector, verdict] pairs) and",
22
- "`hold_completes` (true or false). `note` is for people, not the solver.",
22
+ "`hold_completes` and `stills_only`",
23
+ "(true or false). `note` is for people, not the solver.",
23
24
  "",
24
25
  "generic: the fallbacks tried after every vendor's own. `submit_text` is the",
25
26
  "button text probed for a submit control, in order. `feedback` (CSS only) names the",
@@ -37,7 +38,7 @@
37
38
  "response": "On the host page: the field the vendor fills on success. Read first and unconditionally, because hCaptcha's overlay hides the anchor.",
38
39
  "checked": "Inside the checkbox frame: the box shows accepted. Demo pages do not always fill `response`.",
39
40
  "box": "Inside the checkbox frame: the box itself, clicked from the DOM. A vendor without one is found on a photograph. An in-page checkbox that names one is a button with no tick box to find, and is clicked where it is.",
40
- "accepted": "On the host page: the vendor painted its success state. Visibility is part of the test (see TRIBAL_KNOWLEDGE.md).",
41
+ "accepted": "On the host page, or inside the vendor's challenge frame: the vendor painted its success state. Visibility is part of the test (see TRIBAL_KNOWLEDGE.md).",
41
42
  "fresh": "Inside the challenge frame: a new round has painted, with text.",
42
43
  "images": "Inside the challenge frame: the pictures a board is made of; the driver waits for each to have painted.",
43
44
  "tiles": "Inside the challenge frame: the tiles of the board's grid, in reading order. Where each one is placed is read from the DOM, to click it and to watch it reload.",
@@ -52,7 +53,8 @@
52
53
  "piece": "Inside the widget: the piece, measured to steer the slide and dragged directly when there is no track.",
53
54
  "band": "Inside the widget: picture strips a slide rolls by their background, such as DingXiang's restore bands. Which strip rolls, and how far per handle pixel, are dealt per board and cannot be seen in the picture (see TRIBAL_KNOWLEDGE.md), so each strip's background offset is read while the handle moves, and the slide stops when the strip that rolls has rolled as far as the answer's two points are apart.",
54
55
  "refresh": "Inside the widget: the control that deals a new puzzle, pressed when the model answers `refresh`.",
55
- "hold_completes": "A press-and-hold that completes on its own once full, and resets when let go before it has: the fill reaching the answer's `to` is not a release, and the hold lasts until the widget says it is done."
56
+ "hold_completes": "A press-and-hold that completes on its own once full, and resets when let go before it has: the fill reaching the answer's `to` is not a release, and the hold lasts until the widget says it is done.",
57
+ "stills_only": "Every board this vendor deals is a still: none has ever been seen to animate, live or in training. The driver asks such a board at once instead of first filming it for the animation floor (4s a board); a still answer that fails still earns the recording on the next round. Unset, a vendor is filmed before it is asked."
56
58
  },
57
59
  "custom": null,
58
60
  "vendors": {
@@ -189,6 +191,7 @@
189
191
  },
190
192
  "tencent": {
191
193
  "note": "Both in-page and iframe shapes stay (Tencent moved in-host on 2026-08-11; see TRIBAL_KNOWLEDGE.md), and the iframe id is prefix-anchored: `[id*=tcaptcha]` also matched MTCaptcha's iframe and hid that `.mtcap` matched nothing.",
194
+ "stills_only": true,
192
195
  "hosts": [
193
196
  "captcha.gtimg.com",
194
197
  "captcha.qcloud.com"
@@ -216,6 +219,7 @@
216
219
  ]
217
220
  },
218
221
  "yidun": {
222
+ "stills_only": true,
219
223
  "hosts": [
220
224
  "dun.163.com",
221
225
  "cstaticdun.126.net",
@@ -240,6 +244,7 @@
240
244
  ]
241
245
  },
242
246
  "yandex": {
247
+ "stills_only": true,
243
248
  "hosts": [
244
249
  "smartcaptcha.yandexcloud.net"
245
250
  ],
@@ -255,6 +260,7 @@
255
260
  ]
256
261
  },
257
262
  "lemin": {
263
+ "stills_only": true,
258
264
  "hosts": [
259
265
  "leminnow.com"
260
266
  ],
@@ -272,6 +278,7 @@
272
278
  ]
273
279
  },
274
280
  "prosopo": {
281
+ "stills_only": true,
275
282
  "hosts": [
276
283
  "prosopo.io"
277
284
  ],
@@ -281,6 +288,7 @@
281
288
  ]
282
289
  },
283
290
  "mtcaptcha": {
291
+ "stills_only": true,
284
292
  "hosts": [
285
293
  "mtcaptcha.com"
286
294
  ],
@@ -299,6 +307,7 @@
299
307
  ]
300
308
  },
301
309
  "botdetect": {
310
+ "stills_only": true,
302
311
  "hosts": [],
303
312
  "widget": [
304
313
  ".BDC_CaptchaDiv"
@@ -321,6 +330,7 @@
321
330
  },
322
331
  "human": {
323
332
  "note": "The press-and-hold widget. Found by its host-page container whether the button is drawn inline or in the vendor's iframe inside it: the hold is performed on a photograph of the container, so it never needs the frame's DOM.",
333
+ "stills_only": true,
324
334
  "hosts": [],
325
335
  "widget": [
326
336
  "#px-captcha"
@@ -329,6 +339,7 @@
329
339
  },
330
340
  "awswaf": {
331
341
  "note": "The card is drawn in an open shadow root, which the locator engine pierces; its Confirm is found by the text probe.",
342
+ "stills_only": true,
332
343
  "hosts": [
333
344
  "awswaf.com"
334
345
  ],
@@ -338,6 +349,7 @@
338
349
  },
339
350
  "captchafox": {
340
351
  "note": "The puzzle opens in a modal over the \"I am human\" box, which stays on screen, so the modal is a challenge: a widget would be outranked by the box and the box clicked again.",
352
+ "stills_only": true,
341
353
  "hosts": [
342
354
  "captchafox.com"
343
355
  ],
@@ -354,6 +366,7 @@
354
366
  },
355
367
  "dingxiang": {
356
368
  "note": "Every mode opens the same popup card. The trigger bar under it has no box to tick and is not a widget.",
369
+ "stills_only": true,
357
370
  "hosts": [
358
371
  "cdn.dingxiang-inc.com/ctu-group/captcha",
359
372
  "cap.dingxiang-inc.com"
@@ -372,6 +385,7 @@
372
385
  },
373
386
  "funcaptcha": {
374
387
  "note": "The host page carries the outer frame (iframe.arkoselabs.com/<key>/index.html) and the game is two frames inside it; the game frame's own path is listed so a page that frames the game directly is found too.",
388
+ "stills_only": true,
375
389
  "hosts": [
376
390
  "arkoselabs.com"
377
391
  ],
@@ -383,6 +397,7 @@
383
397
  },
384
398
  "proton": {
385
399
  "note": "Proton frames its own captcha at /core/v4/captcha, on account-api.proton.me or under the app's own /api/.",
400
+ "stills_only": true,
386
401
  "hosts": [
387
402
  "/core/v4/captcha"
388
403
  ],
@@ -395,6 +410,7 @@
395
410
  },
396
411
  "datadome": {
397
412
  "note": "The interstitial is one full-viewport iframe served from geo.captcha-delivery.com/captcha/, so it is the challenge itself, with no checkbox. Its visual mode is a slide-to-the-end bar; the handle is `.slider` inside `.sliderContainer`, and a pass reloads the host page. A refused session gets a 'You have been blocked' page in the same frame, under the same URL.",
413
+ "stills_only": true,
398
414
  "hosts": [
399
415
  "captcha-delivery.com"
400
416
  ],
@@ -409,7 +425,8 @@
409
425
  ],
410
426
  "refresh": [
411
427
  "#captcha__reload__button"
412
- ]
428
+ ],
429
+ "accepted": ".sliderContainer.slider-success .slider"
413
430
  },
414
431
  "cybersiara": {
415
432
  "note": "SiaraShield draws its challenge inline on the host page: a modal (`#myModal .pluginPopups`) holding a looping GIF of four letters read out of noise, `#Input_Captcha` and a refresh. It checks the answer itself once the fourth letter is typed (measured live 2026-11-14: a wrong answer clears the box and deals a new GIF), so it has no submit control. The host's own `.CaptchaSubmit` opens the modal, so it is never pressed for an answer.",
@@ -470,6 +470,14 @@ def _frame_of(at: Any) -> Optional[Any]:
470
470
  return None
471
471
 
472
472
 
473
+ def _still_shown(element: Any) -> bool:
474
+ """The element is attached and visible; one that cannot be asked is taken as gone."""
475
+ try:
476
+ return bool(element.is_visible())
477
+ except Exception:
478
+ return False
479
+
480
+
473
481
  def _host_scopes(page: Any, enclaves: Sequence[str]) -> List[Any]:
474
482
  """Where the host-page selectors are read: the page, then the inside of every VISIBLE vendor enclave. A hidden enclave
475
483
  is skipped because Playwright judges an element visible within its own document, whatever its frame's visibility."""
@@ -1428,11 +1436,11 @@ class PageSolver:
1428
1436
  self._human.press(page)
1429
1437
  self._human.pause(PauseKind.GRAB)
1430
1438
  rest = self._read_bands(bands) if bands else None
1431
- self._screenshot(element, first, timeout_ms=timeout)
1439
+ self._screenshot(element, first, timeout_ms=timeout, scale="css")
1432
1440
  k = self._shot_scale(first, w)
1433
1441
  self._smooth_move(page, press[0] + probe, press[1])
1434
1442
  self._human.pause(PauseKind.PROBE)
1435
- self._screenshot(element, probed, timeout_ms=timeout)
1443
+ self._screenshot(element, probed, timeout_ms=timeout, scale="css")
1436
1444
  ask = dict(probe_s=probe * k, goal=(goal[0] * k, goal[1] * k), seed=seed and (seed[0] * k, seed[1] * k),
1437
1445
  handle=(handle[0] * k, handle[1] * k), bounds=(-handle[0] * k, (w - handle[0]) * k),
1438
1446
  tol=self.config.slide_tolerance_px * k)
@@ -1471,7 +1479,7 @@ class PageSolver:
1471
1479
  self._human.pause(PauseKind.PROBE)
1472
1480
  moves += 1
1473
1481
  if rolling is None:
1474
- self._screenshot(element, current, timeout_ms=timeout)
1482
+ self._screenshot(element, current, timeout_ms=timeout, scale="css")
1475
1483
  look = current
1476
1484
  self._human.pause(PauseKind.SETTLE)
1477
1485
  finally:
@@ -1603,12 +1611,18 @@ class PageSolver:
1603
1611
  if any(self._has_value(scopes, s) for s in self._sel.response) or _visible_in(scopes, self._sel.accepted):
1604
1612
  return True
1605
1613
  for probe in self._sel.widget_probes:
1606
- checked = self._sel.selectors[probe.vendor].checked
1607
- if probe.role != FrameRole.CHECKBOX or not checked:
1608
- continue
1609
- at = next(iter(_visible_in(scopes, (probe.selector,))), None)
1610
- if at is not None and self._checked_in(at, checked):
1611
- return True
1614
+ vendor = self._sel.selectors[probe.vendor]
1615
+ if probe.role == FrameRole.CHECKBOX and vendor.checked:
1616
+ at = next(iter(_visible_in(scopes, (probe.selector,))), None)
1617
+ if at is not None and self._checked_in(at, vendor.checked):
1618
+ return True
1619
+ elif probe.role == FrameRole.CHALLENGE and vendor.accepted:
1620
+ # A vendor that draws its whole challenge in one frame (DataDome) paints its pass in there,
1621
+ # then reloads the page about a second later: unread, the next round filmed the closing frame.
1622
+ at = next(iter(_visible_in(scopes, (probe.selector,))), None)
1623
+ frame = _frame_of(at) if at is not None else None
1624
+ if frame is not None and _visible(frame, (vendor.accepted,)):
1625
+ return True
1612
1626
  except Exception:
1613
1627
  pass
1614
1628
  return False
@@ -1754,24 +1768,29 @@ class PageSolver:
1754
1768
  # ── frames and polling ───────────────────────────────────────────────
1755
1769
 
1756
1770
  def _screenshot(self, element: Any, path: str, timeout_ms: Optional[int] = None,
1757
- animations: str = "disabled", style: Optional[str] = None) -> None:
1771
+ animations: str = "disabled", style: Optional[str] = None, scale: str = "device") -> None:
1758
1772
  """Every capture the driver takes: the whole viewport, cropped here to the element.
1759
1773
 
1760
1774
  Never a clipped capture. An element screenshot, or any `clip`, makes a headed Chromium repaint the page at
1761
1775
  the clip's size for that frame, which the user watches as the page flashing and jumping; a viewport
1762
1776
  capture repaints nothing, and measured twice as fast. Short timeout; `disabled` freezes CSS animation,
1763
- so bursts and the keyframe gate pass `allow`. `style` is CSS applied for this capture only.
1777
+ so bursts and the keyframe gate pass `allow`. `style` is CSS applied for this capture only. `scale="css"`
1778
+ takes one pixel per CSS pixel: the slide loop's choice, since on a phone (DPR 2.6) a device-pixel frame is
1779
+ seven times the pixels and its tracking took 4.7 s of an 11.6 s solve.
1764
1780
  """
1765
1781
  timeout = 2_500 if timeout_ms is None else timeout_ms
1766
1782
  page = self._page
1767
1783
  view = _viewport_of(page)
1768
1784
  rect = self._rect_in_view(element, view) if _layout_is_the_viewport(page, view) else None
1785
+ # Device scale is Playwright's default, so only the slide loop's css changes the call.
1786
+ kw: Dict[str, Any] = {"scale": scale} if scale != "device" else {}
1769
1787
  if rect is None:
1770
1788
  # Bigger than the viewport, or a zoomed-out mobile layout: no viewport capture holds it in its own
1771
1789
  # coordinates, so the element photographs itself.
1772
- _shot(element.screenshot, style, path=path, timeout=timeout, animations=animations)
1790
+ _shot(element.screenshot, style, path=path, timeout=timeout, animations=animations, **kw)
1773
1791
  return
1774
- png = crop_png(_shot(page.screenshot, style, timeout=timeout, animations=animations), rect, view["width"])
1792
+ png = crop_png(_shot(page.screenshot, style, timeout=timeout, animations=animations, **kw), rect,
1793
+ view["width"])
1775
1794
  with open(path, "wb") as fh:
1776
1795
  fh.write(png)
1777
1796
 
@@ -1838,6 +1857,10 @@ class PageSolver:
1838
1857
  self._screenshot(element, path)
1839
1858
  except Exception:
1840
1859
  _unlink(path)
1860
+ # A widget that has closed will not come back to be shot. Retrying it spent the whole
1861
+ # 9s settle window on DataDome's frame closing over an accepted slide; the JS port returns.
1862
+ if not _still_shown(element):
1863
+ return None
1841
1864
  _delay(interval_ms)
1842
1865
  continue
1843
1866
  frames.append(path)
@@ -2007,6 +2030,10 @@ class PageSolver:
2007
2030
  # that recording brings back is what decides — `_known_animated` is set from it, not from here.
2008
2031
  if not self._animated_probe_armed or self._animated_probe_done:
2009
2032
  return False
2033
+ if not _still_shown(element):
2034
+ # Closing, most often over an accepted answer: there is nothing to film, and the loop head asks
2035
+ # whether it was accepted.
2036
+ raise AnimatedChallengeError("the widget closed before its second look could film it")
2010
2037
  self._animated_probe_done, self._animated_probe_armed = True, False
2011
2038
  _log("[animated] a second look at a board that did not solve as a still — recording it")
2012
2039
  self._known_animated = animated
@@ -2016,6 +2043,16 @@ class PageSolver:
2016
2043
  _log("[animated] challenge is animated — solving it from keyframes")
2017
2044
  return True
2018
2045
 
2046
+ def _dealt_as_video(self, vendor: Vendor) -> bool:
2047
+ """The vendor dealt this board as a video: waiting for it to settle would only wait out a cycle."""
2048
+ if self._known_animated or self._board_motion(vendor) is not True:
2049
+ return False
2050
+ if not self.config.video_solve_enabled:
2051
+ raise AnimatedChallengeError("the board was dealt as a video and video_solve_enabled is off")
2052
+ _log("[animated] the vendor dealt this board as a video — filming it")
2053
+ self._known_animated = True
2054
+ return True
2055
+
2019
2056
  def _arm_animated_probe(self) -> None:
2020
2057
  if self.config.animated_probe_enabled and not self._animated_probe_done:
2021
2058
  self._animated_probe_armed = True
@@ -2023,9 +2060,19 @@ class PageSolver:
2023
2060
  def _should_speculate(self, puzzle_source: Vendor, text_mode: bool) -> bool:
2024
2061
  # reCAPTCHA is excluded: its dynamic 3x3 replaces tiles in place, so a burst would film a fade and call
2025
2062
  # it a cycle. A text round has nothing to film.
2063
+ # A vendor whose boards are all stills is asked at once: filming it cost every slider and hold 4s of a
2064
+ # 15s budget (measured on the 5.0 Tier 3 run), and a still answer that fails earns the film next round.
2065
+ # So is a board its vendor dealt as a still file; the burst stays for every board no network has described.
2026
2066
  cfg = self.config
2067
+ entry = self._sel.selectors.get(puzzle_source)
2027
2068
  return (cfg.video_solve_enabled and cfg.speculative_burst_enabled and not self._acted_on_board
2028
- and puzzle_source != Vendor.RECAPTCHA and not text_mode)
2069
+ and puzzle_source != Vendor.RECAPTCHA and not text_mode
2070
+ and not (entry is not None and entry.stills_only)
2071
+ and self._board_motion(puzzle_source) is not False)
2072
+
2073
+ def _board_motion(self, vendor: Optional[Vendor]) -> Optional[bool]:
2074
+ """What the vendor's network said about the current board (verdicts.MOTION_SIGNALS), or None."""
2075
+ return self._verdicts.board_motion(vendor) if self._verdicts is not None and vendor is not None else None
2029
2076
 
2030
2077
  def _burst(self, element: Any, known: AbstractSet[str] = frozenset(),
2031
2078
  max_ms: Optional[float] = None) -> Tuple[List[Any], List[str], bool, float, bool]:
@@ -2554,7 +2601,7 @@ class PageSolver:
2554
2601
  filmable = puzzle_source != Vendor.RECAPTCHA and not text_mode
2555
2602
  if filmable and not self._known_animated:
2556
2603
  self._step_off_the_board(page, element)
2557
- is_animated = filmable and self._settle_or_animated(element)
2604
+ is_animated = filmable and (self._dealt_as_video(puzzle_source) or self._settle_or_animated(element))
2558
2605
  # hCaptcha keeps its challenge iframe visible ~2s after the final submit; read as a fresh puzzle it burned ~18s.
2559
2606
  if role == FrameRole.CHALLENGE and self.is_captcha_solved(page):
2560
2607
  _log("solved while waiting for the next round; skipping inference.")
@@ -37,7 +37,8 @@ class VendorSelectors:
37
37
  # Inside the checkbox frame: the box itself, clicked from the DOM. A vendor without one is found on a photograph.
38
38
  # An in-page checkbox that names one is a button with no tick box to find, and is clicked where it is.
39
39
  box: Sequence[str] = ()
40
- # On the host page: the vendor painted its success state. Visibility is part of the test (see TRIBAL_KNOWLEDGE.md).
40
+ # On the host page, or inside the vendor's challenge frame: the vendor painted its success state. Visibility is part
41
+ # of the test (see TRIBAL_KNOWLEDGE.md).
41
42
  accepted: Optional[str] = None
42
43
  # Inside the challenge frame: a new round has painted, with text.
43
44
  fresh: Optional[str] = None
@@ -76,6 +77,10 @@ class VendorSelectors:
76
77
  # A press-and-hold that completes on its own once full, and resets when let go before it has: the fill reaching
77
78
  # the answer's `to` is not a release, and the hold lasts until the widget says it is done.
78
79
  hold_completes: bool = False
80
+ # Every board this vendor deals is a still: none has ever been seen to animate, live or in training. The driver
81
+ # asks such a board at once instead of first filming it for the animation floor (4s a board), and a still
82
+ # answer that fails still earns the recording on the next round. Unset, a vendor is filmed before it is asked.
83
+ stills_only: bool = False
79
84
 
80
85
 
81
86
  #: The default config: the repository's own `captchakraken.config.json` when this package runs from a checkout, so an
@@ -128,7 +133,7 @@ def _entry(where: str, raw: Any, hosts_required: bool = True) -> VendorSelectors
128
133
  if value is not None and not isinstance(value, str):
129
134
  raise SelectorConfigError(f"{at}: must be one selector string")
130
135
  kw[key] = value
131
- elif key == "hold_completes":
136
+ elif key in ("hold_completes", "stills_only"):
132
137
  if not isinstance(value, bool):
133
138
  raise SelectorConfigError(f"{at}: must be true or false")
134
139
  kw[key] = value
@@ -9,7 +9,7 @@ from __future__ import annotations
9
9
 
10
10
  import json
11
11
  from dataclasses import dataclass
12
- from typing import Any, Callable, List, Mapping, Optional, Sequence, Tuple
12
+ from typing import Any, Callable, Dict, List, Mapping, Optional, Sequence, Tuple
13
13
 
14
14
  from .kinds import Verdict, Vendor
15
15
 
@@ -141,6 +141,118 @@ def read_verdict(url: str, status: int, body: str) -> Optional[RoundVerdict]:
141
141
  return RoundVerdict(vendor, verdict) if verdict is not None else None
142
142
 
143
143
 
144
+ # ── whether a board moves, read off the file it is dealt as ─────────────────
145
+ # Measured 2026-11-14 on the live demos. hCaptcha (46 deals over three sitekeys) loads each board from
146
+ # imgs*.hcaptcha.com/tip/: image/jpeg for every still deal, video/webm for every animated one. GeeTest v4's /load names
147
+ # its challenge in plain JSONP, and only the two svg types moved (22 deals over seven demo pages). A vendor, file or
148
+ # type not listed here gives no hint, and the driver films the board to find out, as it always has.
149
+ _GEETEST_MOVING = frozenset({"svg_icon", "svg_seed"})
150
+ _GEETEST_STILL = frozenset({"slide", "icon", "nine", "match", "winlinze"})
151
+
152
+
153
+ def _media_moves(content_type: str, _body: str) -> Optional[bool]:
154
+ # A GIF may move, so it says nothing either way; every still hCaptcha board measured was a jpeg or a png.
155
+ kind = content_type.split(";", 1)[0].strip().lower()
156
+ if kind == "image/gif":
157
+ return None
158
+ return {"video": True, "image": False}.get(kind.split("/", 1)[0])
159
+
160
+
161
+ def _cybersiara_board_moves(_content_type: str, body: str) -> Optional[bool]:
162
+ # GenerateCaptcha names the board's file in HtmlFormate; every one measured (4 deals) was a GIF that moved.
163
+ data = _json(body)
164
+ board = data.get("HtmlFormate") if isinstance(data, dict) else None
165
+ return True if isinstance(board, str) and board.lower().split("?", 1)[0].endswith(".gif") else None
166
+
167
+
168
+ def _geetest_type_moves(_content_type: str, body: str) -> Optional[bool]:
169
+ start, end = body.find("("), body.rfind(")")
170
+ data = _json(body[start + 1:end]) if 0 <= start < end else None
171
+ kind = (data.get("data") or {}).get("captcha_type") if isinstance(data, dict) else None
172
+ return True if kind in _GEETEST_MOVING else False if kind in _GEETEST_STILL else None
173
+
174
+
175
+ @dataclass(frozen=True)
176
+ class MotionSignal:
177
+ # A URL substring naming the response that carries the board, or names its kind.
178
+ marker: str
179
+ read: Callable[[str, str], Optional[bool]]
180
+ needs_body: bool
181
+
182
+
183
+ MOTION_SIGNALS: Mapping[Vendor, Sequence[MotionSignal]] = {
184
+ Vendor.HCAPTCHA: (MotionSignal("hcaptcha.com/tip/", _media_moves, needs_body=False),),
185
+ Vendor.GEETEST: (MotionSignal("geetest.com/load", _geetest_type_moves, needs_body=True),),
186
+ Vendor.CYBERSIARA: (MotionSignal("mycybersiara.com/api/GenerateCaptcha", _cybersiara_board_moves,
187
+ needs_body=True),),
188
+ }
189
+
190
+
191
+ # ── the same, read back from a frame's performance timeline ──────────────────
192
+ # The listener hears only what loads after solve() starts. A widget the caller opened first, or a board the browser
193
+ # served from its cache, was dealt before then, and each frame's resource timeline still lists what it loaded and what
194
+ # loaded it. Only entries after the vendor's latest deal count, and a full buffer (where new entries are dropped and the
195
+ # latest deal may be missing) says nothing. Measured 2026-11-14: GeeTest's board files sit under
196
+ # static.geetest.com/captcha_v4/policy/<id>/<captcha_type>/, hCaptcha's under /tip/ loaded by an img, CyberSiara's as
197
+ # a GIF under embed.mycybersiara.com/CyberSiara/.
198
+ TIMELINE_JS = """() => {
199
+ const all = performance.getEntriesByType('resource');
200
+ return {full: all.length >= 250, entries: all.map(e => [e.initiatorType, e.name])};
201
+ }"""
202
+
203
+
204
+ def _hcaptcha_tip_moves(initiator: str, _url: str) -> Optional[bool]:
205
+ return True if initiator in ("video", "audio", "source") else False if initiator == "img" else None
206
+
207
+
208
+ def _geetest_path_moves(_initiator: str, url: str) -> Optional[bool]:
209
+ parts = url.split("captcha_v4/policy/", 1)[-1].split("/")
210
+ kind = parts[1] if len(parts) > 1 else None
211
+ return True if kind in _GEETEST_MOVING else False if kind in _GEETEST_STILL else None
212
+
213
+
214
+ def _cybersiara_file_moves(_initiator: str, url: str) -> Optional[bool]:
215
+ return True if url.lower().split("?", 1)[0].endswith(".gif") else None
216
+
217
+
218
+ @dataclass(frozen=True)
219
+ class TimelineBoard:
220
+ deal: str
221
+ board: str
222
+ read: Callable[[str, str], Optional[bool]]
223
+
224
+
225
+ TIMELINE_BOARDS: Mapping[Vendor, TimelineBoard] = {
226
+ Vendor.HCAPTCHA: TimelineBoard("hcaptcha.com/getcaptcha/", "hcaptcha.com/tip/", _hcaptcha_tip_moves),
227
+ Vendor.GEETEST: TimelineBoard("geetest.com/load", "static.geetest.com/captcha_v4/policy/", _geetest_path_moves),
228
+ Vendor.CYBERSIARA: TimelineBoard("mycybersiara.com/api/GenerateCaptcha", "mycybersiara.com/CyberSiara/",
229
+ _cybersiara_file_moves),
230
+ }
231
+
232
+
233
+ def motion_from_timeline(vendor: Vendor, timeline: Any) -> Optional[bool]:
234
+ """What one frame's resource timeline says about the vendor's latest board, or None."""
235
+ spec = TIMELINE_BOARDS.get(vendor)
236
+ if spec is None or not isinstance(timeline, dict) or timeline.get("full"):
237
+ return None
238
+ entries = [e for e in timeline.get("entries") or () if isinstance(e, (list, tuple)) and len(e) == 2]
239
+ last_deal = max((i for i, (_kind, url) in enumerate(entries) if spec.deal in str(url)), default=None)
240
+ if last_deal is None:
241
+ return None
242
+ reads = [spec.read(str(kind), str(url)) for kind, url in entries[last_deal + 1:] if spec.board in str(url)]
243
+ return True if True in reads else False if False in reads else None
244
+
245
+
246
+ def motion_signal_for(url: str) -> Optional[Tuple[Vendor, MotionSignal]]:
247
+ return next(((vendor, s) for vendor, signals in MOTION_SIGNALS.items() for s in signals if s.marker in url), None)
248
+
249
+
250
+ def _deals_a_board(url: str) -> Optional[Vendor]:
251
+ """The vendor whose deal endpoint this is: what it said about the last board no longer holds."""
252
+ found = endpoint_for(url)
253
+ return found[0] if found is not None and found[1].read is _url_only else None
254
+
255
+
144
256
  def _is_a_scripted_request(response: Any) -> bool:
145
257
  try:
146
258
  return response.request.resource_type in _SCRIPTED_REQUESTS
@@ -160,6 +272,9 @@ class VerdictLog:
160
272
  #: Requests the page's scripts have made. A board that answers a press with none has refused nothing.
161
273
  self.exchanges = 0
162
274
  self._read = 0
275
+ #: What each vendor's network said about its current board: True moves, False is still.
276
+ self._motion: Dict[Vendor, bool] = {}
277
+ self._deals: Dict[Vendor, int] = {}
163
278
  self._page = page
164
279
  self._attached = False
165
280
  try:
@@ -173,17 +288,52 @@ class VerdictLog:
173
288
  url, status = response.url, response.status
174
289
  if _is_a_scripted_request(response):
175
290
  self.exchanges += 1
176
- if endpoint_for(url) is None:
291
+ dealt = _deals_a_board(url)
292
+ if dealt is not None:
293
+ # Before the body is read: the new board's own file can arrive while it is.
294
+ self._motion.pop(dealt, None)
295
+ self._deals[dealt] = self._deals.get(dealt, 0) + 1
296
+ signal = motion_signal_for(url)
297
+ # A body read for an earlier deal must not describe a board that has since been replaced.
298
+ deal = self._deals.get(signal[0], 0) if signal is not None else 0
299
+ if endpoint_for(url) is None and signal is None:
177
300
  return
178
301
  # Decoded leniently, as a browser's text() is: one deal endpoint answers in ciphertext, and its URL alone
179
302
  # is the signal.
180
- body = response.body().decode("utf-8", "replace") if status != _TOO_MANY_REQUESTS else ""
303
+ needs_body = endpoint_for(url) is not None or (signal is not None and signal[1].needs_body)
304
+ body = response.body().decode("utf-8", "replace") if needs_body and status != _TOO_MANY_REQUESTS else ""
305
+ content_type = (response.headers or {}).get("content-type", "") if signal is not None else ""
181
306
  except Exception:
182
307
  return
308
+ if signal is not None and 200 <= status < 300 and self._deals.get(signal[0], 0) == deal:
309
+ self._note_motion(signal[0], signal[1].read(content_type, body))
183
310
  verdict = read_verdict(url, status, body)
184
311
  if verdict is not None:
185
312
  self.verdicts.append(verdict)
186
313
 
314
+ def _note_motion(self, vendor: Vendor, moves: Optional[bool]) -> None:
315
+ # One moving file makes the board a moving one: a board may also load a still example.
316
+ if moves is not None and not self._motion.get(vendor):
317
+ self._motion[vendor] = moves
318
+
319
+ def board_motion(self, vendor: Vendor) -> Optional[bool]:
320
+ """Whether the vendor dealt its current board as a moving one; None when neither its network nor a frame's
321
+ timeline has said."""
322
+ heard = self._motion.get(vendor)
323
+ if heard is not None or vendor not in TIMELINE_BOARDS:
324
+ return heard
325
+ try:
326
+ frames = list(self._page.frames)
327
+ except Exception:
328
+ return None
329
+ reads = []
330
+ for frame in frames:
331
+ try:
332
+ reads.append(motion_from_timeline(vendor, frame.evaluate(TIMELINE_JS)))
333
+ except Exception:
334
+ continue
335
+ return True if True in reads else False if False in reads else None
336
+
187
337
  @property
188
338
  def listening(self) -> bool:
189
339
  return self._attached