Improved puppeteer bypass, enabled for Team Skeet.

This commit is contained in:
DebaucheryLibrarian 2023-06-10 02:05:59 +02:00
parent 09a48ed064
commit 80334843c9
7 changed files with 1065 additions and 170 deletions

View File

@ -303,6 +303,7 @@ module.exports = {
enable: false, enable: false,
hostnames: [ // these can run in the same browser session hostnames: [ // these can run in the same browser session
'www.kink.com', 'www.kink.com',
'store2.psmcdn.net', // Team Skeet API
], ],
}, },
cloudflare: { cloudflare: {

1194
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -125,9 +125,9 @@
"postgraphile-plugin-connection-filter": "^2.2.2", "postgraphile-plugin-connection-filter": "^2.2.2",
"promise-task-queue": "^1.2.0", "promise-task-queue": "^1.2.0",
"prop-types": "^15.7.2", "prop-types": "^15.7.2",
"puppeteer": "^18.2.0", "puppeteer": "^20.5.0",
"puppeteer-extra": "^3.3.4", "puppeteer-extra": "^3.3.6",
"puppeteer-extra-plugin-stealth": "^2.11.1", "puppeteer-extra-plugin-stealth": "^2.11.2",
"sharp": "^0.29.2", "sharp": "^0.29.2",
"showdown": "^1.9.1", "showdown": "^1.9.1",
"source-map-support": "^0.5.16", "source-map-support": "^0.5.16",

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 446 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

View File

@ -143,9 +143,9 @@ function getLimiter(options = {}, url) {
return limiters[interval][concurrency]; return limiters[interval][concurrency];
} }
function extractJson(solution) { function extractJson(body, headers) {
if (solution.headers['content-type'].includes('application/json')) { if (headers['content-type'].includes('application/json')) {
const { document } = new JSDOM(solution.response, { virtualConsole }).window; const { document } = new JSDOM(body, { virtualConsole }).window;
const dataString = document.querySelector('body > pre')?.textContent; const dataString = document.querySelector('body > pre')?.textContent;
if (dataString) { if (dataString) {
@ -155,14 +155,14 @@ function extractJson(solution) {
} }
} }
return solution.response; return body;
} }
async function getBrowserSession(identifier, options = {}) { async function getBrowserSession(identifier, options = {}) {
return limiters.bypass.schedule(async () => { return limiters.bypass.schedule(async () => {
if (!browser) { if (!browser) {
browser = await puppeteer.launch({ browser = await puppeteer.launch({
headless: typeof options.headless === 'undefined' ? true : options.headless, headless: typeof options.headless === 'undefined' ? 'new' : options.headless,
// headless: false, // headless: false,
}); });
@ -178,20 +178,24 @@ async function getBrowserSession(identifier, options = {}) {
} }
async function bypassBrowserRequest(url, _options) { async function bypassBrowserRequest(url, _options) {
const page = await getBrowserSession(new URL(url).hostname); const { tab } = await getBrowserSession(new URL(url).hostname);
const res = await page.goto(url); const res = await tab.goto(url);
const body = await page.content(); const rawBody = await tab.content();
console.log(res); const headers = res.headers();
console.log(res.status()); const body = extractJson(rawBody, headers);
const statusCode = res.status();
if (!statusCode === 200) {
throw new Error(`Puppeteer bypass failed for ${url} (${statusCode}): ${body?.message}`);
}
return { return {
body, body,
/* statusCode,
statusCode: res.body.solution.status, headers,
headers: res.body.solution.headers,
*/
}; };
} }
@ -287,7 +291,7 @@ async function bypassCloudflareRequest(url, method, body, cloudflareBypass, opti
throw new Error(`CloudFlare bypass failed for ${url} (${res.statusCode}): ${res.body?.message}`); throw new Error(`CloudFlare bypass failed for ${url} (${res.statusCode}): ${res.body?.message}`);
} }
const resBody = extractJson(res.body.solution); const resBody = extractJson(res.body.solution.response, res.body.solution.headers);
return { return {
body: resBody, body: resBody,