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 🙏

© 2024 – Pkg Stats / Ryan Hefner

captcha-manager

v1.3.0

Published

A Node.js library used for creating and harvesting Google ReCAPTCHA response tokens

Downloads

18

Readme

captcha-manager

A Node.js module used for creating and harvesting Google ReCAPTCHA response tokens

Video demo

Install

  1. Change directory to your Node.js project in terminal
  2. Run npm install captcha-manager --save

Setup

First of all, you have to edit your hosts file. You'll need to add a new entry for each website you'll be getting captcha tokens from. For example, if you'll be getting tokens from adidas.com, you have to add this to your hosts file: 127.0.0.1 localapi.adidas.com

The respective hosts files on macOS and Windows are /etc/hosts and c:\windows\system32\drivers\etc\hosts.

Usage

Local

Create a Harvester to start getting captcha response tokens.

const {Harvester} = require('captcha-manager');

const harvester = new Harvester();

You can get a captcha response token by calling the getResponse method:

async function run(){
//                                               hostname      sitekey
    const response = await harvester.getResponse('google.com', '6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-');
    console.log(response);
}
run();

This will open your default browser with the captcha(s).

If you want to prioritise getting a certain response token first, just set the third parameter to true. That'll push it to the front of the captchas queue.

await harvester.getResponse('google.com', '6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-');
// -->
await harvester.getResponse('google.com', '6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-', true);

You can also use Promises (however, I would recommend using async & await because it's a lot nicer):

harvester.getResponse('google.com', '6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-').then(response => console.log(response));

Remote

You can also setup a Client, that will get captcha response tokens from a remote Harvester (or "server"). This is useful if, say, you're running a bot on a server somewhere and you want to complete the captchas on your own computer.

First, you need to run the actual Harvester somewhere so that the client can connect to it. Your Harvester will now act as a server.
You can do that by cloning this repository and either running the pre-made script by changing directory to the cloned repository and running node start.js, or by installing it via npm and creating a Harvester in your own project by doing:

const {Harvester} = require('captcha-manager');

const remoteServerPort = 8083;
//                              HTTP port
const harvester = new Harvester(8081, 8082, remoteServerPort);
//                                    Web Socket Server port

Next, you'll have to setup the client. To do that, you'll need the IP address of the computer that's running the Harvester, and the remote server port (which is 8083 if you ran the pre-made start.js script, or whatever you used as the remote server port parameter if you did it manually). You'll also need the secret, which can either get by going to your cloned repository or by going to the node_modules/captcha-manager repository of your Node.js project and then running cat src/.secret. Your secret will have echo'd in terminal if you've used/ran the module at least once by running node start.js and stopping the process afterwards.

Once you have the secret, you can start the Client.

const {Client} = require('captcha-manager');

const ipAddress = 'xx.xx.xx.xx';
const remoteServerPort = 8083;
const secret = '4336a1682f726c17e12c0e902e791b1717e05ba2ef82ec1988a9f3143236d5e7d74177c273c743214a9e64b72bb28fad7909498fa66168d06a5e94ccf47aec64d6f11738267557d7b5cdc8c6e1b6d6b2f7a46c2630af89ab8eb227f097d367366ac5e7a81c1ede165f9b2894a11b2321120ee0ea6c6b5d677a659ca1614b3c58';

const client = new Client(ipAddress, remoteServerPort, secret);

The client has the exact same getResponse method as the Harvester, with the only difference being the tokens coming from your "server".

async function run(){
    const response = await harvester.getResponse('google.com', '6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-');
    console.log(response);
}
run();

// or promises

harvester.getResponse('google.com', '6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-').then(response => console.log(response));