fiptcha 0.1.4 → 0.1.5
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.
- package/package.json +1 -1
- package/src/captcha-grid-solver.js +15 -2
package/package.json
CHANGED
|
@@ -126,6 +126,16 @@ async function classifyGrid(frame, adapter, cells, label, seenTiles) {
|
|
|
126
126
|
return selected;
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
+
async function rememberClickedTile(cells, index, seenTiles) {
|
|
130
|
+
// Clicking a CAPTCHA tile changes its rendered appearance (selection overlay,
|
|
131
|
+
// border, checkmark, etc.). Remember that post-click state immediately so the
|
|
132
|
+
// next sweep does not mistake the selection UI itself for a replacement image
|
|
133
|
+
// and toggle an already-correct tile back off. A genuinely replaced tile will
|
|
134
|
+
// still produce a different fingerprint on the next sweep.
|
|
135
|
+
const image = await cells.nth(index).screenshot({ type: 'png' }).catch(() => null);
|
|
136
|
+
if (image) seenTiles.set(index, checksumBuffer(image));
|
|
137
|
+
}
|
|
138
|
+
|
|
129
139
|
async function visibleText(frame, selector) {
|
|
130
140
|
const matches = frame.locator(selector);
|
|
131
141
|
for (let index = 0; index < await matches.count().catch(() => 0); index += 1) {
|
|
@@ -163,7 +173,10 @@ async function solveImageGrid(page, { captchaType, deadline, waitForToken, logs
|
|
|
163
173
|
// Grid cells live inside a provider iframe. Let Playwright target the
|
|
164
174
|
// element in that frame instead of sending a page-level mouse click:
|
|
165
175
|
// the latter can miss the cell when iframe coordinates change.
|
|
166
|
-
for (const index of selected)
|
|
176
|
+
for (const index of selected) {
|
|
177
|
+
await cells.nth(index).click({ timeout: 2000 });
|
|
178
|
+
await rememberClickedTile(cells, index, seenTiles);
|
|
179
|
+
}
|
|
167
180
|
totalSelections += selected.length;
|
|
168
181
|
if (!selected.length) break;
|
|
169
182
|
await page.waitForTimeout(600);
|
|
@@ -177,4 +190,4 @@ async function solveImageGrid(page, { captchaType, deadline, waitForToken, logs
|
|
|
177
190
|
return null;
|
|
178
191
|
}
|
|
179
192
|
|
|
180
|
-
module.exports = { PROVIDERS, normalizePrompt, normalizeModelLabel, normalizeBox, pngDimensions, mapDetectionsToCells, classifyGrid, visibleText, solveImageGrid };
|
|
193
|
+
module.exports = { PROVIDERS, normalizePrompt, normalizeModelLabel, normalizeBox, pngDimensions, mapDetectionsToCells, classifyGrid, rememberClickedTile, visibleText, solveImageGrid };
|