npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

playwright-captcha-kraken-js

v1.0.6

Published

Playwright wrapper which uses CaptchaKraken-cli to solve captchas.

Readme

PlaywrightCaptchaKrakenJS

⭐ If this captcha solver was useful to you, please leave a star on GitHub!

A Patchright (Playwright) wrapper for CaptchaKraken-cli to solve captchas (Recaptcha, hCaptcha, Cloudflare Turnstile) using AI vision models.

Current Capabilities

Right now, we can reliably solve:

  • Checkbox captchas: ~100% success rate
  • Image captchas: ~60% success rate (work in progress with finetuning vision models to improve this)

Other kinds of captchas have not really been tested. Development will primarily focus on reCAPTCHA, Cloudflare Turnstile, and hCaptcha.

Prerequisites

  1. Node.js and npm.
  2. Python 3.10+ installed.

Installation

npm install playwright-captcha-kraken-js patchright-core

If you're cloning this repository, initialize the git submodule:

git submodule update --init --recursive

On install, this package will automatically create a local venv at CaptchaKraken-cli/.venv and install Python dependencies via an npm postinstall hook.

  • Skip python setup: set CAPTCHA_KRAKEN_SKIP_PYTHON_SETUP=1
  • Use a specific python: set CAPTCHA_KRAKEN_PYTHON=/path/to/python3

Note: Setup your environment variables (API keys) in .env if needed or pass them in config.

Usage

import { chromium } from 'patchright';
import { CaptchaKrakenSolver } from 'playwright-captcha-kraken-js';

(async () => {
  const browser = await chromium.launch({ headless: false });
  const page = await browser.newPage();
  
  // Configure the solver
  const solver = new CaptchaKrakenSolver({
    // Optional overrides:
    // repoPath: '/absolute/path/to/CaptchaKraken-cli', // Usually not needed (auto-resolved from npm package)
    // model: 'gemini-2.5-flash-lite',      // Default
    // apiProvider: 'gemini',               // Default
    // apiKey: 'YOUR_API_KEY',              // Defaults to process.env.GEMINI_API_KEY
    // pythonCommand: 'python3',            // Usually not needed (auto-uses venv python)
  });

  await page.goto('https://www.google.com/recaptcha/api2/demo');

  // Attempt to solve the captcha
  // This will detect the captcha, screenshot it, call the CLI, and execute clicks.
  // It will also automatically re-check for newly opened next-step challenges
  // (e.g., checkbox -> image grid) and keep solving until solved (or loop limit).
  await solver.solve(page);

  await browser.close();
})();

Configuration

| Option | Type | Default | Description | |---|---|---|---| | repoPath | string | (auto) | Path to the bundled CaptchaKraken-cli directory (usually not needed). | | pythonCommand | string | (auto) | Python command to use. Usually not needed - automatically uses the venv python created during installation. | | model | string | 'gemini-2.5-flash-lite' (Gemini) or 'google/gemini-2.0-flash-lite-preview-02-05:free' (OpenRouter) | The vision model to use. | | apiProvider | 'ollama' \| 'gemini' \| 'openrouter' | 'gemini' | The API provider. | | apiKey | string | process.env.GEMINI_API_KEY or process.env.OPENROUTER_KEY | API Key (required for Gemini and OpenRouter). | | maxSolveLoops | number | 10 | Max number of detect→solve iterations in a single solve() call. | | postSolveDelayMs | number | 1200 | Delay after each iteration before re-detecting. | | overallSolveTimeoutMs | number | 120000 | Overall time limit for the whole solve() call. |

Coming Soon

We're actively working on several improvements to enhance the solver's capabilities:

  • Stronger default model: Replacing gemini-2.5-flash-lite with a more capable default model that better handles complex image recognition tasks
  • Improved reCAPTCHA accuracy: Finetuned custom model to boost reCAPTCHA image captcha success rate from ~60% to 95%+
  • hCaptcha complex drag puzzle solving: Full support for hCaptcha's drag-and-drop puzzle challenges

Testing

To run the tests:

npm test

End-to-End Solving Tests

To run the real-world solving tests (which connect to your local CaptchaKraken-cli), you can optionally provide environment variables to override defaults:

MODEL="llama3.2-vision" \
API_PROVIDER="ollama" \
npx playwright test tests/solving.spec.ts

Note: The tests will automatically use ./CaptchaKraken-cli as the default path. You can override it with CAPTCHA_KRAKEN_REPO_PATH if needed.

These tests will:

  1. Navigate to demo pages (Recaptcha, hCaptcha, Turnstile).
  2. Attempt to solve the captcha using your local CLI setup.
  3. Verify that the solution was accepted.