Socket
Socket
Sign inDemoInstall

puppeteer-extra-plugin-recaptcha

Package Overview
Dependencies
27
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.5.0 to 3.6.0

34

dist/content-hcaptcha.js

@@ -5,6 +5,6 @@ "use strict";

exports.ContentScriptDefaultOpts = {
visualFeedback: true,
visualFeedback: true
};
exports.ContentScriptDefaultData = {
solutions: [],
solutions: []
};

@@ -55,3 +55,3 @@ /**

_findActiveChallenges() {
const nodeList = document.querySelectorAll(`div[style*='visible'] iframe[src*='${this.baseUrl}'][src*='hcaptcha-challenge.html'][src*='invisible']`);
const nodeList = document.querySelectorAll(`div[style*='visible'] iframe[src*='${this.baseUrl}'][src*='hcaptcha.html']`);
return Array.from(nodeList);

@@ -61,4 +61,4 @@ }

return iframes
.map((el) => el.src.replace('.html#', '.html?'))
.map((url) => {
.map(el => el.src.replace('.html#', '.html?'))
.map(url => {
const { searchParams } = new URL(url);

@@ -71,4 +71,4 @@ const result = {

display: {
size: searchParams.get('size') || 'normal',
},
size: searchParams.get('size') || 'normal'
}
};

@@ -81,3 +81,3 @@ return result;

captchas: [],
error: null,
error: null
};

@@ -88,3 +88,3 @@ try {

...this._findRegularCheckboxes(),
...this._findActiveChallenges(),
...this._findActiveChallenges()
];

@@ -95,3 +95,3 @@ if (!iframes.length) {

result.captchas = this._extractInfoFromIframes(iframes);
iframes.forEach((el) => {
iframes.forEach(el => {
this._paintCaptchaBusy(el);

@@ -109,3 +109,3 @@ });

solved: [],
error: null,
error: null
};

@@ -120,5 +120,5 @@ try {

result.solved = solutions
.filter((solution) => solution._vendor === 'hcaptcha')
.filter((solution) => solution.hasSolution === true)
.map((solution) => {
.filter(solution => solution._vendor === 'hcaptcha')
.filter(solution => solution.hasSolution === true)
.map(solution => {
window.postMessage(JSON.stringify({

@@ -131,4 +131,4 @@ id: solution.id,

expiration: 120,
response: solution.text,
},
response: solution.text
}
}), '*');

@@ -139,3 +139,3 @@ return {

isSolved: true,
solvedAt: new Date(),
solvedAt: new Date()
};

@@ -142,0 +142,0 @@ });

/*!
* puppeteer-extra-plugin-recaptcha v3.4.0 by berstend
* puppeteer-extra-plugin-recaptcha v3.5.0 by berstend
* https://github.com/berstend/puppeteer-extra/tree/master/packages/puppeteer-extra-plugin-recaptcha

@@ -521,6 +521,6 @@ * @license MIT

const ContentScriptDefaultOpts$1 = {
visualFeedback: true,
visualFeedback: true
};
const ContentScriptDefaultData$1 = {
solutions: [],
solutions: []
};

@@ -571,3 +571,3 @@ /**

_findActiveChallenges() {
const nodeList = document.querySelectorAll(`div[style*='visible'] iframe[src*='${this.baseUrl}'][src*='hcaptcha-challenge.html'][src*='invisible']`);
const nodeList = document.querySelectorAll(`div[style*='visible'] iframe[src*='${this.baseUrl}'][src*='hcaptcha.html']`);
return Array.from(nodeList);

@@ -577,4 +577,4 @@ }

return iframes
.map((el) => el.src.replace('.html#', '.html?'))
.map((url) => {
.map(el => el.src.replace('.html#', '.html?'))
.map(url => {
const { searchParams } = new URL(url);

@@ -587,4 +587,4 @@ const result = {

display: {
size: searchParams.get('size') || 'normal',
},
size: searchParams.get('size') || 'normal'
}
};

@@ -597,3 +597,3 @@ return result;

captchas: [],
error: null,
error: null
};

@@ -604,3 +604,3 @@ try {

...this._findRegularCheckboxes(),
...this._findActiveChallenges(),
...this._findActiveChallenges()
];

@@ -611,3 +611,3 @@ if (!iframes.length) {

result.captchas = this._extractInfoFromIframes(iframes);
iframes.forEach((el) => {
iframes.forEach(el => {
this._paintCaptchaBusy(el);

@@ -625,3 +625,3 @@ });

solved: [],
error: null,
error: null
};

@@ -636,5 +636,5 @@ try {

result.solved = solutions
.filter((solution) => solution._vendor === 'hcaptcha')
.filter((solution) => solution.hasSolution === true)
.map((solution) => {
.filter(solution => solution._vendor === 'hcaptcha')
.filter(solution => solution.hasSolution === true)
.map(solution => {
window.postMessage(JSON.stringify({

@@ -647,4 +647,4 @@ id: solution.id,

expiration: 120,
response: solution.text,
},
response: solution.text
}
}), '*');

@@ -655,3 +655,3 @@ return {

isSolved: true,
solvedAt: new Date(),
solvedAt: new Date()
};

@@ -670,3 +670,2 @@ });

// TODO: Create our own API wrapper
var http = require('http');
var https = require('https');

@@ -676,4 +675,4 @@ var url = require('url');

var apiKey;
var apiInUrl = 'http://2captcha.com/in.php';
var apiResUrl = 'http://2captcha.com/res.php';
var apiInUrl = 'https://2captcha.com/in.php';
var apiResUrl = 'https://2captcha.com/res.php';
var SOFT_ID = '2589';

@@ -687,3 +686,3 @@ var defaultOptions = {

var intervalId = setInterval(function () {
var httpRequestOptions = url.parse(apiResUrl +
var httpsRequestOptions = url.parse(apiResUrl +
'?action=get&soft_id=' +

@@ -695,3 +694,3 @@ SOFT_ID +

captchaId);
var request = http.request(httpRequestOptions, function (response) {
var request = https.request(httpsRequestOptions, function (response) {
var body = '';

@@ -716,3 +715,3 @@ response.on('data', function (chunk) {

}
callback = function () { }; // prevent the callback from being called more than once, if multiple http requests are open at the same time.
callback = function () { }; // prevent the callback from being called more than once, if multiple https requests are open at the same time.
});

@@ -735,4 +734,4 @@ });

}
var httpRequestOptions = url.parse(apiInUrl);
httpRequestOptions.method = 'POST';
var httpsRequestOptions = url.parse(apiInUrl);
httpsRequestOptions.method = 'POST';
var postData = Object.assign({ method: captchaMethod, key: apiKey, soft_id: SOFT_ID,

@@ -748,3 +747,3 @@ // googlekey: captcha,

postData = querystring.stringify(postData);
var request = http.request(httpRequestOptions, function (response) {
var request = https.request(httpsRequestOptions, function (response) {
var body = '';

@@ -794,3 +793,3 @@ response.on('data', function (chunk) {

var options = url.parse(reportUrl);
var request = http.request(options, function (response) {
var request = https.request(options, function (response) {
// var body = ''

@@ -855,2 +854,6 @@ // response.on('data', function(chunk) {

}
if (process.env['2CAPTCHA_PROXY_TYPE'] && process.env['2CAPTCHA_PROXY_ADDRESS']) {
extraData['proxytype'] = process.env['2CAPTCHA_PROXY_TYPE'].toUpperCase();
extraData['proxy'] = process.env['2CAPTCHA_PROXY_ADDRESS'];
}
const { err, result, invalid } = await decodeRecaptchaAsync(token, captcha._vendor, captcha.sitekey, captcha.url, extraData);

@@ -985,3 +988,3 @@ debug('Got response', { err, result, invalid });

}
const hasHcaptchaScriptTag = await page.$(`script[src*="//hcaptcha.com/1/api.js"]`);
const hasHcaptchaScriptTag = await page.$(`script[src*="hcaptcha.com/1/api.js"]`);
this.debug('hasHcaptchaScriptTag', !!hasHcaptchaScriptTag);

@@ -988,0 +991,0 @@ if (hasHcaptchaScriptTag) {

/*!
* puppeteer-extra-plugin-recaptcha v3.4.0 by berstend
* puppeteer-extra-plugin-recaptcha v3.5.0 by berstend
* https://github.com/berstend/puppeteer-extra/tree/master/packages/puppeteer-extra-plugin-recaptcha

@@ -515,6 +515,6 @@ * @license MIT

const ContentScriptDefaultOpts$1 = {
visualFeedback: true,
visualFeedback: true
};
const ContentScriptDefaultData$1 = {
solutions: [],
solutions: []
};

@@ -565,3 +565,3 @@ /**

_findActiveChallenges() {
const nodeList = document.querySelectorAll(`div[style*='visible'] iframe[src*='${this.baseUrl}'][src*='hcaptcha-challenge.html'][src*='invisible']`);
const nodeList = document.querySelectorAll(`div[style*='visible'] iframe[src*='${this.baseUrl}'][src*='hcaptcha.html']`);
return Array.from(nodeList);

@@ -571,4 +571,4 @@ }

return iframes
.map((el) => el.src.replace('.html#', '.html?'))
.map((url) => {
.map(el => el.src.replace('.html#', '.html?'))
.map(url => {
const { searchParams } = new URL(url);

@@ -581,4 +581,4 @@ const result = {

display: {
size: searchParams.get('size') || 'normal',
},
size: searchParams.get('size') || 'normal'
}
};

@@ -591,3 +591,3 @@ return result;

captchas: [],
error: null,
error: null
};

@@ -598,3 +598,3 @@ try {

...this._findRegularCheckboxes(),
...this._findActiveChallenges(),
...this._findActiveChallenges()
];

@@ -605,3 +605,3 @@ if (!iframes.length) {

result.captchas = this._extractInfoFromIframes(iframes);
iframes.forEach((el) => {
iframes.forEach(el => {
this._paintCaptchaBusy(el);

@@ -619,3 +619,3 @@ });

solved: [],
error: null,
error: null
};

@@ -630,5 +630,5 @@ try {

result.solved = solutions
.filter((solution) => solution._vendor === 'hcaptcha')
.filter((solution) => solution.hasSolution === true)
.map((solution) => {
.filter(solution => solution._vendor === 'hcaptcha')
.filter(solution => solution.hasSolution === true)
.map(solution => {
window.postMessage(JSON.stringify({

@@ -641,4 +641,4 @@ id: solution.id,

expiration: 120,
response: solution.text,
},
response: solution.text
}
}), '*');

@@ -649,3 +649,3 @@ return {

isSolved: true,
solvedAt: new Date(),
solvedAt: new Date()
};

@@ -664,3 +664,2 @@ });

// TODO: Create our own API wrapper
var http = require('http');
var https = require('https');

@@ -670,4 +669,4 @@ var url = require('url');

var apiKey;
var apiInUrl = 'http://2captcha.com/in.php';
var apiResUrl = 'http://2captcha.com/res.php';
var apiInUrl = 'https://2captcha.com/in.php';
var apiResUrl = 'https://2captcha.com/res.php';
var SOFT_ID = '2589';

@@ -681,3 +680,3 @@ var defaultOptions = {

var intervalId = setInterval(function () {
var httpRequestOptions = url.parse(apiResUrl +
var httpsRequestOptions = url.parse(apiResUrl +
'?action=get&soft_id=' +

@@ -689,3 +688,3 @@ SOFT_ID +

captchaId);
var request = http.request(httpRequestOptions, function (response) {
var request = https.request(httpsRequestOptions, function (response) {
var body = '';

@@ -710,3 +709,3 @@ response.on('data', function (chunk) {

}
callback = function () { }; // prevent the callback from being called more than once, if multiple http requests are open at the same time.
callback = function () { }; // prevent the callback from being called more than once, if multiple https requests are open at the same time.
});

@@ -729,4 +728,4 @@ });

}
var httpRequestOptions = url.parse(apiInUrl);
httpRequestOptions.method = 'POST';
var httpsRequestOptions = url.parse(apiInUrl);
httpsRequestOptions.method = 'POST';
var postData = Object.assign({ method: captchaMethod, key: apiKey, soft_id: SOFT_ID,

@@ -742,3 +741,3 @@ // googlekey: captcha,

postData = querystring.stringify(postData);
var request = http.request(httpRequestOptions, function (response) {
var request = https.request(httpsRequestOptions, function (response) {
var body = '';

@@ -788,3 +787,3 @@ response.on('data', function (chunk) {

var options = url.parse(reportUrl);
var request = http.request(options, function (response) {
var request = https.request(options, function (response) {
// var body = ''

@@ -849,2 +848,6 @@ // response.on('data', function(chunk) {

}
if (process.env['2CAPTCHA_PROXY_TYPE'] && process.env['2CAPTCHA_PROXY_ADDRESS']) {
extraData['proxytype'] = process.env['2CAPTCHA_PROXY_TYPE'].toUpperCase();
extraData['proxy'] = process.env['2CAPTCHA_PROXY_ADDRESS'];
}
const { err, result, invalid } = await decodeRecaptchaAsync(token, captcha._vendor, captcha.sitekey, captcha.url, extraData);

@@ -979,3 +982,3 @@ debug('Got response', { err, result, invalid });

}
const hasHcaptchaScriptTag = await page.$(`script[src*="//hcaptcha.com/1/api.js"]`);
const hasHcaptchaScriptTag = await page.$(`script[src*="hcaptcha.com/1/api.js"]`);
this.debug('hasHcaptchaScriptTag', !!hasHcaptchaScriptTag);

@@ -982,0 +985,0 @@ if (hasHcaptchaScriptTag) {

@@ -136,3 +136,3 @@ "use strict";

}
const hasHcaptchaScriptTag = await page.$(`script[src*="//hcaptcha.com/1/api.js"]`);
const hasHcaptchaScriptTag = await page.$(`script[src*="hcaptcha.com/1/api.js"]`);
this.debug('hasHcaptchaScriptTag', !!hasHcaptchaScriptTag);

@@ -139,0 +139,0 @@ if (hasHcaptchaScriptTag) {

@@ -18,3 +18,3 @@ "use strict";

args: PUPPETEER_ARGS,
headless: true,
headless: true
});

@@ -41,6 +41,6 @@ const page = await browser.newPage();

args: PUPPETEER_ARGS,
headless: true,
headless: true
});
const page = await browser.newPage();
const url = 'http://democaptcha.com/demo-form-eng/hcaptcha.html';
const url = 'https://democaptcha.com/demo-form-eng/hcaptcha.html';
await page.goto(url, { waitUntil: 'networkidle0' });

@@ -56,2 +56,27 @@ const { captchas, error } = await page.findRecaptchas();

});
(0, ava_1.default)('will detect active hCAPTCHA challenges', async (t) => {
const puppeteer = (0, puppeteer_extra_1.addExtra)(require('puppeteer'));
const recaptchaPlugin = (0, index_1.default)();
puppeteer.use(recaptchaPlugin);
const browser = await puppeteer.launch({
args: PUPPETEER_ARGS,
headless: true
});
const page = await browser.newPage();
const url = 'https://democaptcha.com/demo-form-eng/hcaptcha.html';
await page.goto(url, { waitUntil: 'networkidle0' });
await page.evaluate(() => window.hcaptcha.execute()); // trigger challenge popup
await page.waitForTimeout(2 * 1000);
await page.evaluate(() => document
.querySelector(`[data-hcaptcha-widget-id]:not([src*='invisible'])`)
.remove()); // remove regular checkbox so we definitely test against the popup
const { captchas, error } = await page.findRecaptchas();
t.is(error, null);
t.is(captchas.length, 1);
const c = captchas[0];
t.is(c._vendor, 'hcaptcha');
t.is(c.url, url);
t.true(c.sitekey && c.sitekey.length > 5);
await browser.close();
});
(0, ava_1.default)('will not throw when no captchas are found', async (t) => {

@@ -63,3 +88,3 @@ const puppeteer = (0, puppeteer_extra_1.addExtra)(require('puppeteer'));

args: PUPPETEER_ARGS,
headless: true,
headless: true
});

@@ -66,0 +91,0 @@ const page = await browser.newPage();

@@ -6,3 +6,2 @@ "use strict";

exports.report = exports.solveRecaptchaFromHtml = exports.decodeUrl = exports.decodeReCaptcha = exports.decode = exports.setApiKey = void 0;
var http = require('http');
var https = require('https');

@@ -12,4 +11,4 @@ var url = require('url');

var apiKey;
var apiInUrl = 'http://2captcha.com/in.php';
var apiResUrl = 'http://2captcha.com/res.php';
var apiInUrl = 'https://2captcha.com/in.php';
var apiResUrl = 'https://2captcha.com/res.php';
var apiMethod = 'base64';

@@ -24,3 +23,3 @@ var SOFT_ID = '2589';

var intervalId = setInterval(function () {
var httpRequestOptions = url.parse(apiResUrl +
var httpsRequestOptions = url.parse(apiResUrl +
'?action=get&soft_id=' +

@@ -32,3 +31,3 @@ SOFT_ID +

captchaId);
var request = http.request(httpRequestOptions, function (response) {
var request = https.request(httpsRequestOptions, function (response) {
var body = '';

@@ -53,3 +52,3 @@ response.on('data', function (chunk) {

}
callback = function () { }; // prevent the callback from being called more than once, if multiple http requests are open at the same time.
callback = function () { }; // prevent the callback from being called more than once, if multiple https requests are open at the same time.
});

@@ -73,4 +72,4 @@ });

}
var httpRequestOptions = url.parse(apiInUrl);
httpRequestOptions.method = 'POST';
var httpsRequestOptions = url.parse(apiInUrl);
httpsRequestOptions.method = 'POST';
var postData = {

@@ -83,3 +82,3 @@ method: apiMethod,

postData = querystring.stringify(postData);
var request = http.request(httpRequestOptions, function (response) {
var request = https.request(httpsRequestOptions, function (response) {
var body = '';

@@ -126,4 +125,4 @@ response.on('data', function (chunk) {

}
var httpRequestOptions = url.parse(apiInUrl);
httpRequestOptions.method = 'POST';
var httpsRequestOptions = url.parse(apiInUrl);
httpsRequestOptions.method = 'POST';
var postData = Object.assign({ method: captchaMethod, key: apiKey, soft_id: SOFT_ID,

@@ -139,3 +138,3 @@ // googlekey: captcha,

postData = querystring.stringify(postData);
var request = http.request(httpRequestOptions, function (response) {
var request = https.request(httpsRequestOptions, function (response) {
var body = '';

@@ -182,7 +181,4 @@ response.on('data', function (chunk) {

}
var protocol = http;
if (uri.indexOf('https') == 0)
protocol = https;
var options = url.parse(uri);
var request = protocol.request(options, function (response) {
var request = https.request(options, function (response) {
var body = '';

@@ -216,7 +212,4 @@ response.setEncoding('base64');

googleUrl = 'https://www.google.com/recaptcha/api/challenge?k=' + googleUrl;
var protocol = http;
if (googleUrl.indexOf('https') == 0)
protocol = https;
var httpRequestOptions = url.parse(googleUrl);
var request = protocol.request(httpRequestOptions, function (response) {
var httpsRequestOptions = url.parse(googleUrl);
var request = https.request(httpsRequestOptions, function (response) {
var body = '';

@@ -253,3 +246,3 @@ response.on('data', function (chunk) {

var options = url.parse(reportUrl);
var request = http.request(options, function (response) {
var request = https.request(options, function (response) {
// var body = ''

@@ -256,0 +249,0 @@ // response.on('data', function(chunk) {

@@ -80,2 +80,6 @@ "use strict";

}
if (process.env['2CAPTCHA_PROXY_TYPE'] && process.env['2CAPTCHA_PROXY_ADDRESS']) {
extraData['proxytype'] = process.env['2CAPTCHA_PROXY_TYPE'].toUpperCase();
extraData['proxy'] = process.env['2CAPTCHA_PROXY_ADDRESS'];
}
const { err, result, invalid } = await decodeRecaptchaAsync(token, captcha._vendor, captcha.sitekey, captcha.url, extraData);

@@ -82,0 +86,0 @@ debug('Got response', { err, result, invalid });

{
"name": "puppeteer-extra-plugin-recaptcha",
"version": "3.5.0",
"version": "3.6.0",
"description": "A puppeteer-extra plugin to solve reCAPTCHAs and hCaptchas automatically.",

@@ -57,3 +57,3 @@ "main": "dist/index.cjs.js",

"puppeteer": "9",
"puppeteer-extra": "^3.2.0",
"puppeteer-extra": "^3.3.0",
"replace-in-files-cli": "^0.3.1",

@@ -79,3 +79,3 @@ "rimraf": "^3.0.0",

},
"gitHead": "008c114b7f056cb1993ea27f45bb837058f62646"
"gitHead": "eebe9fb6f72974e0c98d20b120af9d466cd9bc51"
}

@@ -143,2 +143,5 @@ # puppeteer-extra-plugin-recaptcha [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/berstend/puppeteer-extra/Test/master)](https://github.com/berstend/puppeteer-extra/actions) [![Discord](https://img.shields.io/discord/737009125862408274)](http://scraping-chat.cf) [![npm](https://img.shields.io/npm/dt/puppeteer-extra-plugin-recaptcha.svg)](https://www.npmjs.com/package/puppeteer-extra-plugin-recaptcha) [![npm](https://img.shields.io/npm/v/puppeteer-extra-plugin-recaptcha.svg)](https://www.npmjs.com/package/puppeteer-extra-plugin-recaptcha)

### Proxies
If you want to attach a proxy while running a bypass, set the enviroment variables ``2CAPTCHA_PROXY_TYPE`` and ``2CAPTCHA_PROXY_ADDRESS``
_**Tip:** The recaptcha plugin works really well together with the [stealth plugin](https://github.com/berstend/puppeteer-extra/tree/master/packages/puppeteer-extra-plugin-stealth)._

@@ -284,3 +287,3 @@

args: [
'--disable-features=IsolateOrigins,site-per-process',
'--disable-features=IsolateOrigins,site-per-process,SitePerProcess',
'--flag-switches-begin --disable-site-isolation-trials --flag-switches-end'

@@ -287,0 +290,0 @@ ]

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc