Skip to content

Commit

Permalink
Implemented a fix for puppeteer-extra plugins not working when using …
Browse files Browse the repository at this point in the history
…a proxy.
  • Loading branch information
mdervisaygan committed Sep 9, 2024
1 parent 1b0851d commit 4e787f8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions lib/cjs/module/pageController.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ function getRandomInt(min, max) {

async function pageController({ browser, page, proxy, turnstile, xvfbsession, pid, plugins, killProcess = false, chrome }) {

if (plugins.length > 0) {
for (const plugin of plugins) {
plugin.onPageCreated(page)
}
}

let solveStatus = turnstile

page.on('close', () => {
Expand Down Expand Up @@ -44,6 +38,12 @@ async function pageController({ browser, page, proxy, turnstile, xvfbsession, pi

if (proxy.username && proxy.password) await page.authenticate({ username: proxy.username, password: proxy.password });

if (plugins.length > 0) {
for (const plugin of plugins) {
plugin.onPageCreated(page)
}
}

await page.evaluateOnNewDocument(() => {
Object.defineProperty(MouseEvent.prototype, 'screenX', {
get: function () {
Expand Down
12 changes: 6 additions & 6 deletions lib/esm/module/pageController.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ function getRandomInt(min, max) {

export async function pageController({ browser, page, proxy, turnstile, xvfbsession, pid, plugins, killProcess = false, chrome }) {

if (plugins.length > 0) {
for (const plugin of plugins) {
plugin.onPageCreated(page)
}
}

let solveStatus = turnstile

page.on('close', () => {
Expand Down Expand Up @@ -44,6 +38,12 @@ export async function pageController({ browser, page, proxy, turnstile, xvfbsess

if (proxy.username && proxy.password) await page.authenticate({ username: proxy.username, password: proxy.password });

if (plugins.length > 0) {
for (const plugin of plugins) {
plugin.onPageCreated(page)
}
}

await page.evaluateOnNewDocument(() => {
Object.defineProperty(MouseEvent.prototype, 'screenX', {
get: function () {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "puppeteer-real-browser",
"version": "1.3.11",
"version": "1.3.12",
"description": "This package is designed to bypass puppeteer's bot-detecting captchas such as Cloudflare. It acts like a real browser and can be managed with puppeteer.",
"main": "lib/cjs/index.js",
"module": "lib/esm/index.mjs",
Expand Down

0 comments on commit 4e787f8

Please sign in to comment.