johnalbertini14-glitch/openclaw-skills / skills/0xclanky/captcha-relay
captcha-relay
FlaggedHuman-in-the-loop CAPTCHA solving with two modes: screenshot (default, zero infrastructure) and token relay (requires network access). Screenshot mode captures the page with a grid overlay, sends it to the human, and injects clicks based on their reply. Token relay mode detects CAPTCHA type + sitekey, serves the real widget on a relay page for native solving, and injects the token via CDP.
| File | Kind | Size |
|---|---|---|
| ARCHITECTURE.md | markdown | 4.2 KB |
| README.md | markdown | 4.0 KB |
| SKILL.md | skill md | 3.6 KB |
| TAILSCALE.md | markdown | 3.0 KB |
| _meta.json | config | 458 B |
| browser-relay-cli.js | script | 981 B |
| fallback/screenshot.js | script | 5.2 KB |
| index.js | script | 5.4 KB |
| lib/browser-relay.js | script | 7.9 KB |
| lib/cdp.js | script | 2.8 KB |
| lib/detect.js | script | 2.8 KB |
| lib/inject.js | script | 4.5 KB |
| lib/server.js | script | 2.6 KB |
| lib/templates/browser-relay.html | other | 7.5 KB |
| lib/templates/hcaptcha.html | other | 1.8 KB |
| lib/templates/recaptcha-v2.html | other | 1.9 KB |
| lib/templates/turnstile.html | other | 1.8 KB |
| lib/tunnel.js | script | 4.2 KB |
| package-lock.json | manifest | 17.2 KB |
| package.json | manifest | 443 B |
index.js
View on GitHub#!/usr/bin/env node
/**
* CAPTCHA Relay v2 — Human-in-the-loop CAPTCHA solving
*
* Two modes:
* screenshot (default) — Grid overlay screenshot, human replies with cell numbers, clicks injected.
* No network infrastructure needed.
* relay — Detects CAPTCHA type + sitekey, serves real widget on relay page,
* human solves natively, token injected via CDP.
* Requires Tailscale or tunnel for network access.
*
* Usage:
* node index.js # screenshot mode (default)
* node index.js --mode screenshot # explicit screenshot mode
* node index.js --mode relay # token relay mode
* node index.js --screenshot # alias for --mode screenshot
* node index.js --mode relay --no-tunnel # relay via Tailscale/LAN
*
* As module:
* const { solveCaptcha, solveCaptchaScreenshot } = require('./index');
*/
const { detectCaptcha } = require('./lib/detect');
const { createRelayServer } = require('./lib/server');
const { startTunnel, stopTunnel, getLocalIp, getTailscaleIp } = require('./lib/tunnel');
const { injectToken } = require('./lib/inject');
const { captureAndAnnotate, injectGridClicks } = require('./fallback/screenshot');
async function solveCaptcha(opts = {}) {
const {
cdpPort = 18800,
timeout = 120000,
inject = true,
useTunnel = true,
// Allow manual override
type: overrideType,
sitekey: overrideSitekey,
pageUrl: overridePageUrl,
} = opts;
const log = (msg) => process.stderr.write(`[captcha-relay] ${msg}\n`);
// Step 1: Detect CAPTCHA
log('Detecting CAPTCHA...');
let detection;
if (overrideType && overrideSitekey) {
detection = { type: overrideType, sitekey: overrideSitekey, pageUrl: overridePageUrl };
} else {
detection = await detectCaptcha(cdpPort);
}
if (!detection.type || !detection.sitekey) {
throw new Error('No CAPTCHA detected on page. Detection result: ' + JSON.stringify(detection));
}
log(`Found ${detection.type} with sitekey ${detection.sitekey.substring(0, 20)}...`);
// Step 2: Start relay server
log('Starting relay server...');
const relay = await createRelayServer({
type: detection.type,
sitekey: detection.sitekey,
pageUrl: detection.pageUrl,
timeout,
});
log(`Relay server on port ${relay.port}`);
// Step 3: Get public URL
let tunnel = null;
let url;
if (useTunnel) {
log('Starting tunnel...');
tunnel = await startTunnel(relay.port);
url = tunnel.url;
log(`Public URL: ${url}`);
} else {
const tsIp = getTailscaleIp();
const ip = tsIp || getLocalIp();
url = `http://${ip}:${relay.port}`;
log(`${tsIp ? 'Tailscale' : 'Local'} URL: ${url}`);
}
// Step 4: Output URL for notification (caller sends to Telegram)
const result = {
type: detection.type,
sitekey: detection.sitekey,
pageUrl: detection.pageUrl,
relayUrl: url,
port: relay.port,
isLocal: tunnel ? tunnel.isLocal : true,
};
// Output URL immediately so caller can send notification
console.log(JSON.stringify({ event: 'ready', ...result }));
// Step 5: Wait for token
log('Waiting for human to solve CAPTCHA...');
const token = await relay.waitForToken();
if (!token) {
stopTunnel(tunnel);
throw new Error('CAPTCHA solving timed out');
}
log(`Token received (${token.length} chars)`);
// Step 6: Inject token
if (inject) {
log('Injecting token...');
const injectResult = await injectToken({
type: detection.type,
token,
cdpPort,
});
log(`Injection result: ${injectResult}`);
result.injected = true;
result.injectionMethod = injectResult;
}
result.token = token;
result.solved = true;
// Cleanup
stopTunnel(tunnel);
console.log(JSON.stringify({ event: 'solved', ...result }));
return result;
}
/**
* Screenshot-based fallback for when token relay can't work
*/
async function solveCaptchaScreenshot(opts = {}) {
const { cdpPort = 18800 } = opts;
const log = (msg) => process.stderr.write(`[captcha-relay] ${msg}\n`);
log('Using screenshot fallback...');
const capture = await captureAndAnnotate(cdpPort);
console.log(JSON.stringify({
event: 'screenshot-ready',
imagePath: capture.imagePath,
prompt: capture.prompt,
rows: capture.rows,
cols: capture.cols,
totalCells: capture.totalCells,
}));
return capture;
}
// CLI mode
if (require.main === module) {
const args = process.argv.slice(2);
const getArg = (name, def) => {
const i = args.indexOf(name);
return i >= 0 ? args[i + 1] : def;
};
const hasFlag = (name) => args.includes(name);
// Determine mode: --mode screenshot|relay, --screenshot as alias
const explicitMode = getArg('--mode', null);
const useScreenshot = hasFlag('--screenshot');
const mode = explicitMode || (useScreenshot ? 'screenshot' : 'screenshot'); // default: screenshot
const opts = {
cdpPort: parseInt(getArg('--cdp-port', '18800')),
timeout: parseInt(getArg('--timeout', '120')) * 1000,
inject: !hasFlag('--no-inject'),
useTunnel: !hasFlag('--no-tunnel'),
};
const run = mode === 'relay' ? solveCaptcha : solveCaptchaScreenshot;
run(opts).catch(e => {
console.error(JSON.stringify({ event: 'error', error: e.message }));
process.exit(1);
});
}
module.exports = { solveCaptcha, solveCaptchaScreenshot, injectGridClicks };
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |