-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFriendlyCaptchaBypass.js
54 lines (43 loc) · 1.54 KB
/
FriendlyCaptchaBypass.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
require("dotenv").config();
const puppeteer = require("puppeteer");
const {
RequestInterceptionManager,
} = require("puppeteer-intercept-and-modify-requests");
let browser, page, client;
let loggedIn = false;
async function main() {
browser = await puppeteer.launch({
headless: false,
slowMo: 150,
defaultViewport: null,
ignoreHTTPSErrors: true,
args: [
"--disable-web-security",
"--disable-dev-shm-usage",
`--proxy-server=${process.env.PROXY_SERVER}`,
"--disable-setuid-sandbox",
"--no-sandbox",
"--unlimited-storage",
"--full-memory-crash-report",
],
});
page = await browser.newPage();
await page.setUserAgent('Mozilla/5.0 (Windows; U; Windows NT 10.2; WOW64; en-US) AppleWebKit/535.16 (KHTML, like Gecko) Chrome/51.0.3655.377 Safari/535.1 Edge/11.89293');
client = await page.target().createCDPSession();
const interceptManager = new RequestInterceptionManager(client);
await interceptManager.intercept({
// specify the URL pattern to intercept:
urlPattern: 'https://unpkg.com/friendly-challenge@0.9.13/widget.module.min.js',
// specify how you want to modify the response (may be async):
modifyResponse({ body }) {
return {
body: body.replaceAll(
'-1===l.indexOf("headless")&&-1===A.appVersion.indexOf("Headless")&&-1===l.indexOf("bot")&&-1===l.indexOf("crawl")&&!0!==A.webdriver&&A.language&&(void 0===A.languages||A.languages.length)',
"true"
),
};
},
});
await page.goto('URL');
}
main();