Skip to content

Commit

Permalink
🚀 1.0.5
Browse files Browse the repository at this point in the history
Jest, linting and other.
  • Loading branch information
notsapinho committed Jun 16, 2022
1 parent 6bf18d3 commit e1c6a06
Show file tree
Hide file tree
Showing 15 changed files with 432 additions and 347 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = tab
indent_size = 4
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,5 @@ typings/
.fusebox/

package-lock.json
dist/
dist/
index.js
11 changes: 6 additions & 5 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"trailingComma": "none",
"tabWidth": 4,
"semi": true,
"printWidth": 140,
"singleQuote": false
"useTabs": true,
"trailingComma": "none",
"tabWidth": 4,
"semi": true,
"printWidth": 140,
"singleQuote": false
}
40 changes: 19 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,30 @@ const CapMonsterProvider = require("puppeteer-extra-plugin-recaptcha-capmonster"
CapMonsterProvider.use(BuiltinSolutionProviders);

puppeteer.use(
RecaptchaPlugin({
provider: {
id: "capmonster",
token: "XXXXXXX" // REPLACE THIS WITH YOUR OWN CAPMONSTER API KEY ⚡
},
visualFeedback: true // colorize reCAPTCHAs (violet = detected, green = solved)
})
RecaptchaPlugin({
provider: {
id: "capmonster",
token: "XXXXXXX" // REPLACE THIS WITH YOUR OWN CAPMONSTER API KEY ⚡
},
visualFeedback: true // colorize reCAPTCHAs (violet = detected, green = solved)
})
);

// puppeteer usage as normal
puppeteer.launch({ headless: true }).then(async (browser) => {
const page = await browser.newPage();
await page.goto("https://www.google.com/recaptcha/api2/demo");

// That's it, a single line of code to solve reCAPTCHAs 🎉
await page.solveRecaptchas();

await Promise.all([
page.waitForNavigation(),
page.click(`#recaptcha-demo-submit`)
]);
await page.screenshot({ path: "response.png", fullPage: true });
await browser.close();
const page = await browser.newPage();
await page.goto("https://www.google.com/recaptcha/api2/demo");

// That's it, a single line of code to solve reCAPTCHAs 🎉
await page.solveRecaptchas();

await Promise.all([page.waitForNavigation(), page.click(`#recaptcha-demo-submit`)]);
await page.screenshot({ path: "response.png", fullPage: true });
await browser.close();
});
```

## Credits
- Thanks to [berstend](https://github.com/berstend) for the original plugin
- Thanks to [hanahaneull](https://github.com/hanahaneull) for the capmonster solver

- Thanks to [berstend](https://github.com/berstend) for the original plugin
- Thanks to [hanahaneull](https://github.com/hanahaneull) for the capmonster solver
27 changes: 27 additions & 0 deletions jest-puppeteer.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require("dotenv/config");

const puppeteer = require("puppeteer-extra");
const { default: RecaptchaPlugin, BuiltinSolutionProviders } = require("puppeteer-extra-plugin-recaptcha");
const CapMonsterProvider = require("./dist/index.cjs.js");

CapMonsterProvider.use(BuiltinSolutionProviders);

puppeteer.use(
RecaptchaPlugin({
provider: {
id: "capmonster",
token: process.env.CAPMONSTER_KEY
},
visualFeedback: true
})
);

if (!process.env.CAPMONSTER_KEY) {
console.error('\nCAPMONSTER_KEY not set in ".env"');
process.exit();
}

// Change jest-puppeteer "puppeteer" to "puppeteer-extra"
require.cache[require.resolve("puppeteer")] = require.cache[require.resolve("puppeteer-extra")];

module.exports = {};
5 changes: 5 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
preset: "jest-puppeteer",
verbose: true,
testTimeout: 60000
};
107 changes: 56 additions & 51 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,53 +1,58 @@
{
"name": "puppeteer-extra-plugin-recaptcha-capmonster",
"version": "1.0.4",
"description": "A puppeteer-extra plugin that implements CapMonster support for puppeteer-extra-plugin-recaptcha.",
"types": "dist/index.d.ts",
"main": "dist/index.cjs.js",
"module": "dist/index.esm.ts",
"scripts": {
"build": "npm run build:tsc && npm run build:rollup",
"build:tsc": "tsc --module commonjs",
"build:rollup": "rollup -c rollup.config.ts"
},
"files": [
"dist"
],
"keywords": [
"puppeteer",
"puppeteer-extra",
"puppeteer-extra-plugin",
"puppeteer-extra-plugin-recaptcha",
"puppeteer-extra-plugin-recaptcha-capmonster",
"recaptcha",
"hcaptcha",
"captcha",
"2captcha",
"capmonster"
],
"repository": {
"type": "git",
"url": "https://github.com/notsapinho/puppeteer-extra-plugin-recaptcha-capmonster.git"
},
"author": "notsapinho",
"license": "MIT",
"devDependencies": {
"@rollup/plugin-commonjs": "^22.0.0",
"@rollup/plugin-node-resolve": "^13.3.0",
"@rollup/plugin-typescript": "^8.3.3",
"@types/debug": "^4.1.7",
"@types/node": "^16.11.11",
"rollup": "^2.75.6",
"rollup-plugin-sourcemaps": "^0.4.2",
"ts-node": "^10.8.1",
"tslib": "^2.4.0",
"typescript": "^4.7.3"
},
"dependencies": {
"axios": "^0.27.2",
"debug": "^4.3.4"
},
"engines": {
"node": ">=12.0.0"
}
"name": "puppeteer-extra-plugin-recaptcha-capmonster",
"version": "1.0.5",
"description": "A puppeteer-extra plugin that implements CapMonster support for puppeteer-extra-plugin-recaptcha.",
"types": "dist/index.d.ts",
"main": "dist/index.cjs.js",
"module": "dist/index.esm.ts",
"scripts": {
"build": "npm run build:tsc && npm run build:rollup",
"build:tsc": "tsc --module commonjs",
"build:rollup": "rollup -c rollup.config.ts"
},
"files": [
"dist"
],
"keywords": [
"puppeteer",
"puppeteer-extra",
"puppeteer-extra-plugin",
"puppeteer-extra-plugin-recaptcha",
"puppeteer-extra-plugin-recaptcha-capmonster",
"recaptcha",
"hcaptcha",
"captcha",
"2captcha",
"capmonster"
],
"repository": {
"type": "git",
"url": "https://github.com/notsapinho/puppeteer-extra-plugin-recaptcha-capmonster.git"
},
"author": "notsapinho",
"license": "MIT",
"devDependencies": {
"@rollup/plugin-commonjs": "^22.0.0",
"@rollup/plugin-node-resolve": "^13.3.0",
"@rollup/plugin-typescript": "^8.3.3",
"@types/debug": "^4.1.7",
"@types/node": "^16.11.11",
"@types/puppeteer": "^5.4.6",
"dotenv": "^16.0.1",
"jest": "^28.1.1",
"jest-puppeteer": "^6.1.0",
"puppeteer-extra-plugin-recaptcha": "^3.5.0",
"puppeteer-extra-plugin-recaptcha-capmonster": "^1.0.5",
"rollup": "^2.75.6",
"ts-node": "^10.8.1",
"tslib": "^2.4.0",
"typescript": "^4.7.3"
},
"dependencies": {
"axios": "^0.27.2",
"debug": "^4.3.4"
},
"engines": {
"node": ">=12.0.0"
}
}
73 changes: 35 additions & 38 deletions rollup.config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import commonjs from "@rollup/plugin-commonjs";
import resolve from "@rollup/plugin-node-resolve";
import sourceMaps from "rollup-plugin-sourcemaps";
import typescript from "@rollup/plugin-typescript";

const pkg = require("./package.json");
import pkg from "./package.json";

const entryFile = "index";
const banner = `
/*!
* ${pkg.name} v${pkg.version} by ${pkg.author}
* ${pkg.homepage || `https://github.com/${pkg.repository.url}`}
* ${`https://github.com/${pkg.repository.url}`}
* @license ${pkg.license}
*/
`.trim();
Expand All @@ -20,39 +19,37 @@ const defaultExportOutro = `
`;

export default {
input: `src/${entryFile}.ts`,
output: [
{
file: pkg.main,
format: "cjs",
sourcemap: true,
exports: "named",
outro: defaultExportOutro,
banner
},
{
file: pkg.module,
format: "es",
sourcemap: true,
exports: "named",
banner
}
],
// Indicate here external modules you don't wanna include in your bundle (i.e.: 'lodash')
external: [...Object.keys(pkg.dependencies || {}), ...Object.keys(pkg.peerDependencies || {})],
watch: {
include: "src/**"
},
plugins: [
// Compile TypeScript files
typescript(),
// Allow bundling cjs modules (unlike webpack, rollup doesn't understand cjs)
commonjs(),
// Allow node_modules resolution, so you can use 'external' to control
// which external modules to include in the bundle
// https://github.com/rollup/rollup-plugin-node-resolve#usage
resolve(),
// Resolve source maps to the original source
sourceMaps()
]
input: `src/${entryFile}.ts`,
output: [
{
file: pkg.main,
format: "cjs",
sourcemap: true,
exports: "named",
outro: defaultExportOutro,
banner
},
{
file: pkg.module,
format: "es",
sourcemap: true,
exports: "named",
banner
}
],
// Indicate here external modules you don't wanna include in your bundle (i.e.: 'lodash')
external: [...Object.keys(pkg.dependencies || {})],
watch: {
include: "src/**"
},
plugins: [
// Compile TypeScript files
typescript(),
// Allow bundling cjs modules (unlike webpack, rollup doesn't understand cjs)
commonjs(),
// Allow node_modules resolution, so you can use 'external' to control
// which external modules to include in the bundle
// https://github.com/rollup/rollup-plugin-node-resolve#usage
resolve()
]
};
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import * as CapMonster from "./provider/capmonster";
import * as types from "./types/plugin";

class Plugin {
static use(providers: types.SolutionProvider[]) {
providers.push({ id: CapMonster.PROVIDER_ID, fn: CapMonster.getSolutions });
}
static use(providers: types.SolutionProvider[]) {
providers.push({ id: CapMonster.PROVIDER_ID, fn: CapMonster.getSolutions });
}
}

export default Plugin;
Loading

0 comments on commit e1c6a06

Please sign in to comment.