Skip to content

Commit e1c6a06

Browse files
committed
🚀 1.0.5
Jest, linting and other.
1 parent 6bf18d3 commit e1c6a06

File tree

15 files changed

+432
-347
lines changed

15 files changed

+432
-347
lines changed

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
insert_final_newline = true
6+
charset = utf-8
7+
indent_style = tab
8+
indent_size = 4
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,5 @@ typings/
7676
.fusebox/
7777

7878
package-lock.json
79-
dist/
79+
dist/
80+
index.js

.prettierrc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
2-
"trailingComma": "none",
3-
"tabWidth": 4,
4-
"semi": true,
5-
"printWidth": 140,
6-
"singleQuote": false
2+
"useTabs": true,
3+
"trailingComma": "none",
4+
"tabWidth": 4,
5+
"semi": true,
6+
"printWidth": 140,
7+
"singleQuote": false
78
}

README.md

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,30 @@ const CapMonsterProvider = require("puppeteer-extra-plugin-recaptcha-capmonster"
2222
CapMonsterProvider.use(BuiltinSolutionProviders);
2323

2424
puppeteer.use(
25-
RecaptchaPlugin({
26-
provider: {
27-
id: "capmonster",
28-
token: "XXXXXXX" // REPLACE THIS WITH YOUR OWN CAPMONSTER API KEY ⚡
29-
},
30-
visualFeedback: true // colorize reCAPTCHAs (violet = detected, green = solved)
31-
})
25+
RecaptchaPlugin({
26+
provider: {
27+
id: "capmonster",
28+
token: "XXXXXXX" // REPLACE THIS WITH YOUR OWN CAPMONSTER API KEY ⚡
29+
},
30+
visualFeedback: true // colorize reCAPTCHAs (violet = detected, green = solved)
31+
})
3232
);
3333

3434
// puppeteer usage as normal
3535
puppeteer.launch({ headless: true }).then(async (browser) => {
36-
const page = await browser.newPage();
37-
await page.goto("https://www.google.com/recaptcha/api2/demo");
38-
39-
// That's it, a single line of code to solve reCAPTCHAs 🎉
40-
await page.solveRecaptchas();
41-
42-
await Promise.all([
43-
page.waitForNavigation(),
44-
page.click(`#recaptcha-demo-submit`)
45-
]);
46-
await page.screenshot({ path: "response.png", fullPage: true });
47-
await browser.close();
36+
const page = await browser.newPage();
37+
await page.goto("https://www.google.com/recaptcha/api2/demo");
38+
39+
// That's it, a single line of code to solve reCAPTCHAs 🎉
40+
await page.solveRecaptchas();
41+
42+
await Promise.all([page.waitForNavigation(), page.click(`#recaptcha-demo-submit`)]);
43+
await page.screenshot({ path: "response.png", fullPage: true });
44+
await browser.close();
4845
});
4946
```
5047

5148
## Credits
52-
- Thanks to [berstend](https://github.com/berstend) for the original plugin
53-
- Thanks to [hanahaneull](https://github.com/hanahaneull) for the capmonster solver
49+
50+
- Thanks to [berstend](https://github.com/berstend) for the original plugin
51+
- Thanks to [hanahaneull](https://github.com/hanahaneull) for the capmonster solver

jest-puppeteer.config.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
require("dotenv/config");
2+
3+
const puppeteer = require("puppeteer-extra");
4+
const { default: RecaptchaPlugin, BuiltinSolutionProviders } = require("puppeteer-extra-plugin-recaptcha");
5+
const CapMonsterProvider = require("./dist/index.cjs.js");
6+
7+
CapMonsterProvider.use(BuiltinSolutionProviders);
8+
9+
puppeteer.use(
10+
RecaptchaPlugin({
11+
provider: {
12+
id: "capmonster",
13+
token: process.env.CAPMONSTER_KEY
14+
},
15+
visualFeedback: true
16+
})
17+
);
18+
19+
if (!process.env.CAPMONSTER_KEY) {
20+
console.error('\nCAPMONSTER_KEY not set in ".env"');
21+
process.exit();
22+
}
23+
24+
// Change jest-puppeteer "puppeteer" to "puppeteer-extra"
25+
require.cache[require.resolve("puppeteer")] = require.cache[require.resolve("puppeteer-extra")];
26+
27+
module.exports = {};

jest.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
preset: "jest-puppeteer",
3+
verbose: true,
4+
testTimeout: 60000
5+
};

package.json

Lines changed: 56 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,58 @@
11
{
2-
"name": "puppeteer-extra-plugin-recaptcha-capmonster",
3-
"version": "1.0.4",
4-
"description": "A puppeteer-extra plugin that implements CapMonster support for puppeteer-extra-plugin-recaptcha.",
5-
"types": "dist/index.d.ts",
6-
"main": "dist/index.cjs.js",
7-
"module": "dist/index.esm.ts",
8-
"scripts": {
9-
"build": "npm run build:tsc && npm run build:rollup",
10-
"build:tsc": "tsc --module commonjs",
11-
"build:rollup": "rollup -c rollup.config.ts"
12-
},
13-
"files": [
14-
"dist"
15-
],
16-
"keywords": [
17-
"puppeteer",
18-
"puppeteer-extra",
19-
"puppeteer-extra-plugin",
20-
"puppeteer-extra-plugin-recaptcha",
21-
"puppeteer-extra-plugin-recaptcha-capmonster",
22-
"recaptcha",
23-
"hcaptcha",
24-
"captcha",
25-
"2captcha",
26-
"capmonster"
27-
],
28-
"repository": {
29-
"type": "git",
30-
"url": "https://github.com/notsapinho/puppeteer-extra-plugin-recaptcha-capmonster.git"
31-
},
32-
"author": "notsapinho",
33-
"license": "MIT",
34-
"devDependencies": {
35-
"@rollup/plugin-commonjs": "^22.0.0",
36-
"@rollup/plugin-node-resolve": "^13.3.0",
37-
"@rollup/plugin-typescript": "^8.3.3",
38-
"@types/debug": "^4.1.7",
39-
"@types/node": "^16.11.11",
40-
"rollup": "^2.75.6",
41-
"rollup-plugin-sourcemaps": "^0.4.2",
42-
"ts-node": "^10.8.1",
43-
"tslib": "^2.4.0",
44-
"typescript": "^4.7.3"
45-
},
46-
"dependencies": {
47-
"axios": "^0.27.2",
48-
"debug": "^4.3.4"
49-
},
50-
"engines": {
51-
"node": ">=12.0.0"
52-
}
2+
"name": "puppeteer-extra-plugin-recaptcha-capmonster",
3+
"version": "1.0.5",
4+
"description": "A puppeteer-extra plugin that implements CapMonster support for puppeteer-extra-plugin-recaptcha.",
5+
"types": "dist/index.d.ts",
6+
"main": "dist/index.cjs.js",
7+
"module": "dist/index.esm.ts",
8+
"scripts": {
9+
"build": "npm run build:tsc && npm run build:rollup",
10+
"build:tsc": "tsc --module commonjs",
11+
"build:rollup": "rollup -c rollup.config.ts"
12+
},
13+
"files": [
14+
"dist"
15+
],
16+
"keywords": [
17+
"puppeteer",
18+
"puppeteer-extra",
19+
"puppeteer-extra-plugin",
20+
"puppeteer-extra-plugin-recaptcha",
21+
"puppeteer-extra-plugin-recaptcha-capmonster",
22+
"recaptcha",
23+
"hcaptcha",
24+
"captcha",
25+
"2captcha",
26+
"capmonster"
27+
],
28+
"repository": {
29+
"type": "git",
30+
"url": "https://github.com/notsapinho/puppeteer-extra-plugin-recaptcha-capmonster.git"
31+
},
32+
"author": "notsapinho",
33+
"license": "MIT",
34+
"devDependencies": {
35+
"@rollup/plugin-commonjs": "^22.0.0",
36+
"@rollup/plugin-node-resolve": "^13.3.0",
37+
"@rollup/plugin-typescript": "^8.3.3",
38+
"@types/debug": "^4.1.7",
39+
"@types/node": "^16.11.11",
40+
"@types/puppeteer": "^5.4.6",
41+
"dotenv": "^16.0.1",
42+
"jest": "^28.1.1",
43+
"jest-puppeteer": "^6.1.0",
44+
"puppeteer-extra-plugin-recaptcha": "^3.5.0",
45+
"puppeteer-extra-plugin-recaptcha-capmonster": "^1.0.5",
46+
"rollup": "^2.75.6",
47+
"ts-node": "^10.8.1",
48+
"tslib": "^2.4.0",
49+
"typescript": "^4.7.3"
50+
},
51+
"dependencies": {
52+
"axios": "^0.27.2",
53+
"debug": "^4.3.4"
54+
},
55+
"engines": {
56+
"node": ">=12.0.0"
57+
}
5358
}

rollup.config.ts

Lines changed: 35 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import commonjs from "@rollup/plugin-commonjs";
22
import resolve from "@rollup/plugin-node-resolve";
3-
import sourceMaps from "rollup-plugin-sourcemaps";
43
import typescript from "@rollup/plugin-typescript";
54

6-
const pkg = require("./package.json");
5+
import pkg from "./package.json";
76

87
const entryFile = "index";
98
const banner = `
109
/*!
1110
* ${pkg.name} v${pkg.version} by ${pkg.author}
12-
* ${pkg.homepage || `https://github.com/${pkg.repository.url}`}
11+
* ${`https://github.com/${pkg.repository.url}`}
1312
* @license ${pkg.license}
1413
*/
1514
`.trim();
@@ -20,39 +19,37 @@ const defaultExportOutro = `
2019
`;
2120

2221
export default {
23-
input: `src/${entryFile}.ts`,
24-
output: [
25-
{
26-
file: pkg.main,
27-
format: "cjs",
28-
sourcemap: true,
29-
exports: "named",
30-
outro: defaultExportOutro,
31-
banner
32-
},
33-
{
34-
file: pkg.module,
35-
format: "es",
36-
sourcemap: true,
37-
exports: "named",
38-
banner
39-
}
40-
],
41-
// Indicate here external modules you don't wanna include in your bundle (i.e.: 'lodash')
42-
external: [...Object.keys(pkg.dependencies || {}), ...Object.keys(pkg.peerDependencies || {})],
43-
watch: {
44-
include: "src/**"
45-
},
46-
plugins: [
47-
// Compile TypeScript files
48-
typescript(),
49-
// Allow bundling cjs modules (unlike webpack, rollup doesn't understand cjs)
50-
commonjs(),
51-
// Allow node_modules resolution, so you can use 'external' to control
52-
// which external modules to include in the bundle
53-
// https://github.com/rollup/rollup-plugin-node-resolve#usage
54-
resolve(),
55-
// Resolve source maps to the original source
56-
sourceMaps()
57-
]
22+
input: `src/${entryFile}.ts`,
23+
output: [
24+
{
25+
file: pkg.main,
26+
format: "cjs",
27+
sourcemap: true,
28+
exports: "named",
29+
outro: defaultExportOutro,
30+
banner
31+
},
32+
{
33+
file: pkg.module,
34+
format: "es",
35+
sourcemap: true,
36+
exports: "named",
37+
banner
38+
}
39+
],
40+
// Indicate here external modules you don't wanna include in your bundle (i.e.: 'lodash')
41+
external: [...Object.keys(pkg.dependencies || {})],
42+
watch: {
43+
include: "src/**"
44+
},
45+
plugins: [
46+
// Compile TypeScript files
47+
typescript(),
48+
// Allow bundling cjs modules (unlike webpack, rollup doesn't understand cjs)
49+
commonjs(),
50+
// Allow node_modules resolution, so you can use 'external' to control
51+
// which external modules to include in the bundle
52+
// https://github.com/rollup/rollup-plugin-node-resolve#usage
53+
resolve()
54+
]
5855
};

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import * as CapMonster from "./provider/capmonster";
33
import * as types from "./types/plugin";
44

55
class Plugin {
6-
static use(providers: types.SolutionProvider[]) {
7-
providers.push({ id: CapMonster.PROVIDER_ID, fn: CapMonster.getSolutions });
8-
}
6+
static use(providers: types.SolutionProvider[]) {
7+
providers.push({ id: CapMonster.PROVIDER_ID, fn: CapMonster.getSolutions });
8+
}
99
}
1010

1111
export default Plugin;

0 commit comments

Comments
 (0)